#help-development
1 messages · Page 519 of 1
Takes a bit to update
i thought declared referred to methods/fields declared in that class and not in super classes when you want to get methods/fields
well that doesnt really apply to constructors since you can't really call a constructor from a superclass without calling the constructor of the subclass
declared gets type declared members. Non declared gets visible stuff from the outside basically
So inherited visible stuff included
For constructors yea its a bit special
Excuse me
Mom, someone broke their JDK again!
You gotta buy the boolean DLC
MOM, GET THE CAMERA
Am I missing any wood blocks? https://paste.md-5.net/turevereka.makefile
Types that is
me when i get "cannot access java.lang.Object"
Hey, I've programmed a small api and I'm using it in a project.
I add the api using maven. I use the system as scope.
Do I have to put the api also on the server?
If you shade it no
But please don't use system scope
c++ is even more fun than java
That's like the worst way to depend on anything
Use a build system like maven to manage everything for you
how?
Mvn install adds it to your local .m2
why not just put it on the server
Shading is easier less depending for stupid users to manage
why would you mvn install it then
i wanted to add it with the mvn command install-file but it didnt worked
Because that's 200x better than system scope
Which is brain dead design
they said they use maven
or is only the api on maven but not the impl or some weird stuff
Both are maven afaik
I found this $ mvn install:install-file -Dfile=<path-to-file> \ -DgroupId=<group-id> -DartifactId=<artifact-id> \ -Dversion=<version> -Dpackaging=<packaging>
but i didnt know how to put this respectively i dont know how to do the break lines
how? i used this command
-DgroupId=<group-id> -DartifactId=<artifact-id> \
-Dversion=<version> -Dpackaging=<packaging> ```
But i get everytime a CommandNotFoundException
Does your api not use maven
If it does that command isn't needed
Just use mvn install
Is it possible that 2 yml files with configuration settings are copied to the plugin folder, with the content in it i have config.yml & texts.yml, config.yml i can save with
saveDefaultConfig();
``` and how can i get texts.yml to copy top the folder?
i found something, giving levitation 255 effect to player, and he can't jump
saveResource("texts.yml", false)
?jd-s
for the definition
And nothing else changes? About falling, fall damage, swimming?
Potion effects at 255 sometimes break their functions
I know about that. I'm just wondering if there's other sideeffects
Does Bukkit.getScheduler().runTaskLaterAsynchronously use a new thread for each time it's called?
Like, do I need to worry about how much I call this? Cause if each call makes a new thread, that probably wouldn't be ideal
There's a threadpool
and how can i then get that file? bcs getConfig is for config.yml
YamlConfiguration.loadConfiguration(file)
u should have some notion of being worried
but in short it reuses a thread if the consumption becomes high, else there's a timeout cooldown for when it will terminate a thread after being left unused
hello
so i was searching for some minecraft coding free courses
and i didn't really find any
all of them are for 9 years old kids and they explain the most stupid things
do you know any sources ?
i have good experience with java
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ty
or just some good tutorial series on youtube
there probably a re a bunch of videos on whatever you need
still have to find those
i love it when my code randomly starts working even though i changed nothing
Sorry But why this not working? java if (args[1].equals(null)){ player.sendMessage(ChatColor.RED + "Sorry But You Need Set a Name To Create New Round!"); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29); return false;
it should check if args[1] is null or not
but it send me like error in mc
An internal Error occured While Attempting to Perform this command
See the console for the actual error
Also that code is never going to work
You can't call equals on null
org.bukkit.command.CommandException: Unhandled exception executing command 'th' in plugin Treasurehunt v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:916) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.2.jar:git-Paper-307]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.2.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:305) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:289) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2294) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-
?paste
then how say if arg[1] not set we send this Sorry But You Need Set a Name To Create New Round!
Check the length of the array
?learnjava ;/
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I kinda know some basics
You don't know how an array works
But i wasn't know how make that lol
Thank you anyway!
bruh i know
but i never use them ☠️
You just showed me that you have no idea how they work
memory that was gone is suddenly back
Can you help me with something?
?ask
No
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I wanted to mess with them >:(
go learn assembly instead youngling
Assembly college class next year 💀 not excited
it was a bit fun for me
Ur pfo just made me think of haryy potter
and now im writing my own assembly based lang
guys i want this tabcompleter only for like arg 1 or arg 0 how do that? StringUtil.copyPartialMatches(args[0], List.of(arg1tabcompter), completions);
when i change the number in (args[0] it error whole code
StringUtil.copyPartialMatches(args[0], List.of(arg1tabcompter), completions); StringUtil.copyPartialMatches(args[1], List.of(nothing), completions);
should check the args.length
What this do?
How do I make the tnt shoot like the snowball? "
public class Tnttone implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
ItemStack Tnttone = new ItemStack(Material.TNT);
ItemMeta Tnttone_meta = Tnttone.getItemMeta();
Tnttone_meta.setDisplayName("§4§lTnttone");//coso sopra
ArrayList<String> Tnttone_lore = new ArrayList<>();
Tnttone_lore.add("§bInfo:"); //coso sotto
Tnttone_lore.add("§dQuando si prende un oggetto"); //coso sotto
Tnttone_lore.add("§dTenere sempre vuoto il primo Slot"); //coso sotto
Tnttone_meta.setLore(Tnttone_lore);
Tnttone.setItemMeta(Tnttone_meta);
Player player = event.getPlayer();
if (event.getItem().getAmount() == Tnttone.getAmount() && event.getItem().getType() == Tnttone.getType()) {
if(event.getItem().isSimilar(Tnttone)) {
player.launchProjectile(Snowball.class);
launchTNTProjectile(player);
}
}
}
public void launchTNTProjectile(Player player) {
TNTPrimed tnt = player.getWorld().spawn(player.getLocation(), TNTPrimed.class);
tnt.setFuseTicks(40);
new BukkitRunnable() {
@Override
public void run() {
tnt.setVelocity(player.getLocation().getDirection().multiply(10));
}
}.runTaskLater((Plugin) this, 1);
}}?
Checks how many args there is
like if args.length == 1 (meaning you have the command name and one arg) you return a tabcompletion for that arg
i see-
so like if args.length == 0
this should return the tabcomleetion for frist arg?
no you need one arg, like /command arg0
bec arg starts with 0
Also ur copyPartialMatches is wrong (args【num], completions, new ArrayList<>()) then you return this
hm
/commandName arg0 arg1 arg2 ...
Length starts at 1
Too many emojis 
Works!
good
sorry how know like if arg 1 isn't set anything so i send error
You do not send errors in tab complete
you check is args.length is 1
ah i was mean in chat
so you only have args[0]
Really Smart.
none of those args will be null so checking args[x] == null wont work
I Think this not working
it just send error in consel and do nothing java if (args[0].equals("remove")) { if(args.length == 1){ player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]); player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29); return true;
uh do length check before you access an element that may or may not exist
@Override
public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 1){
player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
return true;
}
if (args[0].equals("create")) {
if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\" + args[1]))) {
player.sendMessage(ChatColor.RED + "Sorry But There Are Aready Round Called " + ChatColor.DARK_RED + args[1]);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
return true;
}```
no
ig
if you only know args.length == 1, only args[0] will exist
args.length == 1 -> args[0] exist
2 -> args[0] and 1 exist
3 -> args[0], 1 and 2 exist
yes
I Understanding now
it just counting the args in the command
ah check if arg 0 is "create" and then make folder called arg 1 value that i will enter
yep treasurehunt my plugin name
well you have JavaPlugin#getDataFolder which returns the folder where you can store plugin data (/plugins/treasurehunt in your case)
yep
so could do java File dir = new File(plugin.getDataFolder(), args[1]); if (!dir.exists()) { dir.createNewFile(); } //etc
I'd probably be very much against creating a file on the computer
for some reason will not working ;/
Would be much better to just create 1 config file so you don't have to handle creation/loading every time someone runs a command
frist i need fix this
if(args.length == 2){
player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
return true;
}
if (args[0].equals("create")) {
if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\" + args[1]))) {
player.sendMessage(ChatColor.RED + "Sorry But There Are Aready Round Called " + ChatColor.DARK_RED + args[1]);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
return true;
}```
it do nothing ;/
send error to consel
anyone have any idea way?
cant really see but the 'if args[0].equals("create")' isnt in the 'args.length == 2' block right
so args.length might even be 0
dude i so dumb
no
i used args[1]
here player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round! " + ChatColor.DARK_RED + args[1]);
at end 💀
o wait still not working
you say
still not working
if(args.length == 0){
player.sendMessage(ChatColor.RED + "Sorry But You Need Set A Name To Create The Round!");
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 10, 29);
return true;```
anyone have any other ideas?
whats not working
wait we can just send args length]
1 sec
oth it send 1
it send this An internal error occured while attempting to perform this command
then send error in consel
whats it saying
ArrayIndexOutOfBounds
no shit 🤡
🙂
Wat?
im trying not to spoonfeed 💀
bruh now works
ah i just add args.length == 1
But i learned alot of things today
that google is my best friend and args is hard 💀
Thank You @tardy delta Btw!
why args still not collection?
changing to a collection would be a breaking change
Yea
not really needed either
every toArray() i see triggers me
yea but how can i get the fiel from saveResource("texts.yml, false); ?
File instance?
okay thx
im trying to make a new thread via BukkitRunnable, but this seems to not be making a new thread and instead just lags my server until i close it (though it does run the code, i.e. saying "test" every second). anyone know why?
new BukkitRunnable() {
@Override
public void run() {
try {
while (true) {
Bukkit.broadcastMessage("test");
Thread.sleep(1000);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}.runTask(plugin);```
you need Async to run off the main thread
Example from my Farm Rod source code Bukkit.getScheduler().scheduleSyncRepeatingTask(this, (Runnable)new Runnable() { @Override public void run() { for(FarmRod farm : farms) { if( farm.getType() == FarmType.CROPS || farm.getType() == FarmType.RESOURCES ) { if( farm.getOptionBoolean("Harvest") ) { farm.harvest(); } if( farm.getOptionBoolean("Plant") ) { farm.plant(); } } if( farm.getType() == FarmType.ANIMALS ) { if( farm.getOptionBoolean("Shear") ) { farm.shear(); } } farm.updateViews(); } } }, 0L, 60L);
()-> {}
?
() -> { System.out.println("Hello world"); }
I see what you mean. Its like a JavaScript function but not quiteconst func = () => { console.log("SpigotMC") }Just don't know how it would work withnew Runnable(){}I just trying to help someone with running threads
?scheduling
new Runnable() { void run() { //code } } is () -> { // code }
I will have to test that but what I have works for right now. Plus my code is splitted to multiple files and plugins so there is nothing to make smaller
log check
check the exit code
Odd
did you press ctrl c 💀
This is the config for my scoreboard on my plugin : ```yaml
scoreboard:
#This variable sets the time after each load of the placeholders (dont set this too low)
seconds: 15
title: "&4&lScoreboard"
values:
- ""
- "&a&lStats:"
- "&eKills: &r%statistic_player_kills%"
- "&eDeaths: &r%statistic_deaths%"
- ""
- "&a&lInfo:"
- "&rPing: &c%player_ping%"```Its bugs out, like if i put on the first like on the "" a space like this : " " it leaves the first space if not it doesnt, and if you add 2 spaces it bugs out its wierd does someone know why? or how to fix it?, this is the code for the scoreboard : ```java
//Scoreboard
public void scoreboardLoad(Player player) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = manager.getNewScoreboard();
// Get the scoreboard title from the configuration file
String title = ChatColor.translateAlternateColorCodes('&', getConfig().getString("Config.scoreboard.title"));
// Register a new objective with the title and set it to be displayed in the sidebar
Objective objective = scoreboard.registerNewObjective("title", "title", title);
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
// Get the list of values from the configuration file
List<String> values = getConfig().getStringList("Config.scoreboard.values");
int scoreValue = values.size();
// Loop through each value and add it as a score in the objective
for (String value : values) {
//Adds Colors
Score normalScore = objective.getScore(ChatColor.translateAlternateColorCodes('&', value));
//Checks for placeholderapi
if(hasPapi){
// Adds Placeholders
String papiString = PlaceholderAPI.setPlaceholders(player, value);
Score papiScore = objective.getScore(ChatColor.translateAlternateColorCodes('&', papiString));
papiScore.setScore(scoreValue);
}
else {
normalScore.setScore(scoreValue);
}
// Decrease the score value for the next iteration
scoreValue--;
}
// Set the scoreboard for the player
player.setScoreboard(scoreboard);
}
omg pls use ?paste
weird ahh code
I'd enforce oop
ILLUSION SEARCH INDEX - Simple scoreboard class
public class SimpleBoard {
private static final int MAX_LINES = 15;
// private static final int MAX_PREFIX_LENGTH = 16; - Minecraft now uses Components for this, so we don't need to worry about it
private static final String[] BLANKS = new String[MAX_LINES];
private final Team[] teams = new Team[MAX_LINES];
private final Objective objective;
static {
for (int index = 0; index < MAX_LINES; index++) {
BLANKS[index] = new String(new char[]{ChatColor.COLOR_CHAR, (char) ('s' + index)});
}
}
public SimpleBoard() {
this(Bukkit.getScoreboardManager().getNewScoreboard());
}
public SimpleBoard(Scoreboard board) {
board.clearSlot(DisplaySlot.SIDEBAR);
objective = board.registerNewObjective("sidebar", "dummy", " ");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
for (int index = 0; index < MAX_LINES; index++) {
teams[index] = board.registerNewTeam(BLANKS[index]);
teams[index].addEntry(BLANKS[index]);
}
}
public void setTitle(String title) {
objective.setDisplayName(title);
}
public void setLine(int index, String line) {
if (index < 0 || index >= MAX_LINES) {
throw new IndexOutOfBoundsException("Index must be between 0 and " + MAX_LINES);
}
if (line == null) {
line = "";
}
/*
if (line.length() > MAX_PREFIX_LENGTH) {
line = line.substring(0, MAX_PREFIX_LENGTH);
}
*/
teams[index].setPrefix(line);
objective.getScore(BLANKS[index]).setScore(MAX_LINES - index);
}
public void removeLine(int index) {
if (index < 0 || index >= MAX_LINES) {
throw new IndexOutOfBoundsException("Index must be between 0 and " + MAX_LINES);
}
teams[index].setPrefix(BLANKS[index]);
objective.getScoreboard().resetScores(BLANKS[index]);
}
public void clear() {
for (int index = 0; index < MAX_LINES; index++) {
teams[index].setPrefix(BLANKS[index]);
objective.getScoreboard().resetScores(BLANKS[index]);
}
}
public void displayList(List<String> lines) {
// we can't let this flicker
if (lines.size() > MAX_LINES) {
throw new IllegalArgumentException("List cannot be larger than " + MAX_LINES);
}
for(int index = 0; index < MAX_LINES; index++) {
if (index < lines.size()) {
setLine(index, lines.get(index));
} else {
removeLine(index);
}
}
}
public void display(Player player) {
player.setScoreboard(objective.getScoreboard());
}
public void hide(Player player) {
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
}
public void dispose() {
objective.unregister();
}
}
and then yk
some logic
Or use FastBoard
I am sorry but i thought it was way simpler thanks tho
whats that?
Oh amma check that out
oh just found it its good thanks allot!
lib/framework
noice
question how can i get from the config yaml values: - "" - "&a&lStats:" - "&eKills: &r%statistic_player_kills%" - "&eDeaths: &r%statistic_deaths%" - "" - "&a&lInfo:" - "&rPing: &c%player_ping%" the spaces separated in the list, and add them as fastboard tells you too, that is with separated with commas as the example they give : java // Change the lines board.updateLines( "", // Empty line "One line", "", "Second line" );
Does your list contain the empty strings ?
config.getStringList("values")
If not, create a special character, such as %blankline%, and replace them with ""
Oh yeah my bad i just thought i would need to separate them with commas
Guys I'm making a minigame lobby, and was wondering about team balancing.
Basically my game requires a maximum of 4 teams (4 players max by team), but you can play with only two. As now I work such that:
Only roundup( nbOfPlayers / 4) + 1 teams are opened. Players are put on the team to equalize the average per team (2 per team). But they can switch.
15s before the beginning, if nbOfPlayers <= 12 i only let opened roundUp(nbOfPlayers/4) teams. So I chose the team(s) with the least players and ask them to choose for the remaining teams.
Do you think it's equal, and balanced? Do you have any critics (except that this question is not code related 🙂 )?
Is it possible to customize the break speed of a block
Would I have to mess with packets or nms
Depends how custom you want
You can just give the player haste/mining fatigue when they are mining the block
Least glitchy option
That would make the player swing their arm faster and slower
And wouldn't allow for specific times to the millisecond
Also if they have effects from a beacon or elder guardian and such it would be pretty annoying to handle
Block breaking isn't specific to the millisecond anyway lol
like do you want it to start transforming already generated chunks into void space?
i want to make a new world that is just void
Yes
I think so, it might be compulsory to override one method, but just try and see
dunno what do the docs say
probably if the world with that name is already loaded?
docs don't say that's why I asked
it actually says that it will return the world that already exists if it already exists
?jd-s
?stash I ment
This is not a spigot related question, so this might not be the best place to ask, but I need it for my plugin.
Minecraft texture packs have a font folder at ..\assets\minecraft\textures\font. This folder contains some properties files and character sheets that look something like this (see attached image). I need to somehow convert these into a truetype font file that supports plain, bold and italic styles. Does anyone have any idea how to go about this?
okay it looks like it gets the world, returns that if it isn't null
otherwise tries to create the world
and if for some reason it doesn't exist then it will return null
so if it tries to make the world but it doesn't exist for some reason, that's when it would return null
idk if that can actuall yhappen tbh
makes sense
just gonna Objects.requireNotNull and hope for the best
i want to assign plots in this void world spiraling outward from the center
but I have no clue how to go about doing this
these plots just need to be marked as assigned so that the next time one is needed a different one can be assigned
and they don't need to be saved after restarts
so this just has to happen in memory
hopped in a call with someone and I think I figured it out
something I can try at least
I am trying to use https://github.com/Shynixn/StructureBlockLib to place a structure from an NBT file saved by a structure block. however when i use it like this:
public static void placeStructure(String name, Location location, Consumer<Throwable> onException, Consumer<Void> onResult) {
InputStream stream = Doom.getInstance().getResource("structures/" + name + ".nbt");
StructureBlockLibApi.INSTANCE
.loadStructure(MyPlugin.getInstance())
.at(location)
.loadFromInputStream(stream)
.onException(onException)
.onResult(onResult);
}
It complains about Not in GZIP format. Anyone know how to solve this or maybe an easier structure block API? (FAWE seems to only use paper? pls correct if wrong)
you have to not filter resources when you package your jar
it corrupts zip formatting
could u elaborate pls? also the .nbt file is just saved from a structure block in vanilla minecraft, not a zip file
also how can i disable the filter resources?
in your pom
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
like this?
new to maven
yes, so long as you are not replacing anything in your plugin.yml
if you do you have to make separate resource sections
like ```xml
<resources>
<!-- Include all resources -->
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>.yml</include>
<include>.txt</include>
<include>.json</include>
<include>.properties</include>
</includes>
</resource>
<resource>
<directory>resources</directory>
<filtering>false</filtering>
<includes>
<include>*.nbt</include>
</includes>
</resource>
</resources>```
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/structures</directory>
<filtering>false</filtering>
</resource>
</resources>
would this work?
try it, not sure if resources run the tree
nope its still "not in gzip", i will try ur resource sections then
it still doesnt work
still not in gzip
?paste your resources section
looks fine
and if i can figure out how to use FAWE i would much rather use that since theres almost no resources about this api
maybe its not my nbt file's problem but the API's? this is so confusing
I assume this is pre 1.18
why use a lib for structure blocks? Spigot has an api
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.html this? i didnt find any methods for generating this contents of the structure block
No
org.bukkit.structure iirc
Bukkit.getStructureManager()
you still need to use the filtering setting to include your nbt files though
They are basically zip files which contain the data.
still doesnt work, switched to the bukkit structures manager, but still "not in gzip format"
make sure your files are not corrupt. open them with any zip util
the nbt file is not in a zip file
does it have to be
yes i have the same thing
Automatic Cobble Gen Bukkit.getScheduler().scheduleSyncRepeatingTask(this, (Runnable)new Runnable() { @Override public void run() { for(Hopper hopper : hoppers) { hopper.blockBreak(); } } }, 0L, 20L);
pls ping when anyone has suggestion for me, gonna be afk for a while, thanks in advanc
I've given you everything to make it work. Perhaps your maven jar plugin is breaking it?
One feature I loved about EpicHoppers and the autosell feature which what started the server shop project
I don;t use that plugin
Used to use it but after I got banned from Paypal, I noticed pirated plugins I can get so I started creating plugins. Its worth creating anyways plus programming makes me smile sso why not start?
6 stacks already with 2 running
this is the wrong way to use the scheduler
if you want to use new Runnable(){}, use new BukkitRunnable(){}.runTaskTimer(plugin, 0l, 20l)
but scheduler should use lambda
There's nothing wrong with using a normal Runnable if you don't need the functionality that is offered by a BukkitRunnable. Or am I missing something?
What I don't get is why he casts a Runnable to a Runnable
you cant use #runTaskTimer on a normal runnable
and iirc bukkit has the class runnable method deprecated
?scheduler
you can just call start though
?scheduling
I don't see that warning, maybe its just got there and I using 1.19.3 but once I see it, my code will be changed
then it's a best pratice thing. I wonder why they did not deprecate the legacy methods though
you shouldnt need a warning to change your code, the wiki saying how to use the scheduler tells you how it should be used
@worldly ingot do you know by a chance? I'm obviously not expecting them to be removed but wouldn't a deprecation make sense?
I have a issue now. I have the block breaking which is the cobble gen but how do I get the hopper inventory?
Need to check if the hopper is full so it will stop creating entities in my world
do you have the location of the hopper
I do
Data file```world:193:65:-121:
Location:
World: world
X: 193
Y: 65
Z: -121
world:193:65:-123:
Location:
World: world
X: 193
Y: 65
Z: -123
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Container.html#getInventory() and check if the 5 slots are full
declaration: package: org.bukkit.block, interface: Container
Get block at location, get state
BlockState?
Yes
Thanks, I will look at that
Just need to stop this when full
Having too many entities is bad
Can you save structure locations using StructureBlockLib the vanilla ones.
ugh seems like somebody put alcohol into my beer or sth
Don't mess with StructureBlocks, they crashed my server. Don't ask how, I don't. I just know it crashed the server
Oh they use structure blocks. lmao I was just wanting to having a lib or some that saves the location and it tells you if you been there or not.
structure blocks work fine if they didnt mojang wouldnt use them
I don't know, that is what happened when I was messing with them. It might be another block. You don't see command blocks in creative but you can spawn them. I should not be worrying about this right now. Just be careful what you use
you can get them in gmc in 1.19.3
So I don't think it's possible, but thought I would see if anyone had found a way to run a piece of code when a player clicks, as opposed to running a command. The reason I don't think it is possible is because it is probably entirely handled on the client side, and therefore they need to send something back to the server for the server to know anything got clicked.
How do I get the blockstate?
block.getState
Thanks
player interact event
as far as I am aware, you need to click to interact with the world in minecraft and then in the inventory there is a click event
hi everyone, I'm developing an auth plugin and I searched for several months how could I integrate the premium mode in it. Of course the plugin is made for cracked servers (otherwise there's not sense to make the plugin).
I already asked chatgpt, read tons of threads in Spigot (and I think Bukkit), and also read some FastLogin code but as far as I know FastLogin use a proxy or something like that?
Anyways, after some more deep research I think the """solution""" is to get the bearer token of the player or something similar and check it in the Mojang API but that's not possible as I saw.
Also there's an interesting answer in a thread that I didn't understood => https://www.spigotmc.org/threads/get-access-token.386789/#post-3493675
thank's in advance ^^
you are asking a community for help with something that the majority of the community is against and does not support
if the players you are checking for need to have premium
then I don't see why the server needs to be in offline mode
I'm not asking for code, I'm just asking for at least how does FastLogin exactly checks the authenticity
you could just look at the code
its not hidden
mojang hosts their auth lib on github last I recalled
offline mode to accept cracked people, but need to check for premium so their accounts are more secure and don't need to authenticate themselves with .login 🤓
Use the PlayerCommandPreprocess event and you don’t need to actually register a command
nothing you make is going to be more secure
Granted even with said even it’s still basically just a command
you suggest me to look at the mojang code? lmao I didn't knew they had a github for that
mojang is the one that created the authentication for their servers
not sure what made you think it was something custom
spigot doesn't touch the authentication stuff because that breaks the DMCA for DRM
not really custom. I know FastLogin make requests to the Mojang API, but not only that. As I said I understood something that FastLogin use like a proxy or something to get a token or something
there is a rate limit of 600 requests a minute
that should be plenty sufficient for you
if fastlogin is a login system for offline servers what is it going to ask mojang api for
I don't know, tell me 🤓 https://github.com/games647/FastLogin/tree/main#network-requests
only thing it could really be used for checking if the name is a registered premium user
but like, there is no way to know if the person using the name on the server is the same as what was found
since you know, there isn't any sessions
yeah the github says that
but for offline servers it is pointless to even do this check
then you suggest me to search here? https://github.com/Techcable/Authlib/tree/master
because you can't guarantee that the person who connected is actually the owner of said name
I want at least try it, just for testing
you are better off doing the reverse
you are not by far the first person to even attempt this
but, it isn't going to work and the client is going to complain for those who are premium
I meant clicking on a message, sorry.
Thank you, actually a good idea.
that sounds better lol
Does anyone know how to stop a hopper from working all together?
IE: Its placed, and becomes pretty much a dead block with no states, no ticking, and so on
Im aware You can tweak the ticks and such in the configuration, but i mean more broadly kill the block
There isn’t any way to stop it from ticking afaik
But you can cancel various events to stop it from having any functionality
Yea, that wont work unfortunately, i need to prevent it from ticking
You could also change its state to enabled=false
Clever, ill give that a try
Thank you!
Don't know whether or not that stops its ticking, but it will stop hopping/transferring items
Im having a hard time finding the Hoppers state switch, but ill give it a minute
Thats what i thought, but thats not working as id expect
Icould also make a Hopper manager, Disable all the ticks for hoppers entirely, and have something else manage them entirely
Ie:
All to 0
Then have a whole "Hopper" thread
Disabling this also does not prevent the ticking
Lol
I can actually cancel that // the BlockPhysicsEvent to achieve what i want. Thank you @worldly ingot
@EventHandler
public void on(BlockPlaceEvent e) {
Hopper h = e.getBlock().getType() == Material.HOPPER ? (Hopper) e.getBlock().getState() : null;
BlockState bs = h.getBlock().getState();
org.bukkit.block.data.type.Hopper hopper = (org.bukkit.block.data.type.Hopper) bs.getBlockData();
hopper.setEnabled(false);
bs.setBlockData(hopper);
bs.update(true);
}
// Cancel the event so that the hopper doesn't update
@EventHandler
public void on(BlockPhysicsEvent e) {
if (e.getBlock().getType() == Material.HOPPER) {
e.setCancelled(true);
}
}
in case anyone was curious
How do I get the first item in the overflow list?inv.addItem(new ItemStack(Material.COAL,25))
Its the result
Like if you add an item to an inventory, or items, the retuen or the additem, is a list of items
Eg: if you are getting drops:
List<Item> items = e.getItems().copy();
e.getItems().clear();
for (Item i : items) {
p.playSound(p.getLocation(), Sound.BLOCK_CALCITE_HIT, 0.05f, 0.01f);
xp(p, 2);
if (!p.getInventory().addItem(i.getItemStack()).isEmpty()) {
p.getWorld().dropItem(p.getLocation(), i.getItemStack());
}
}
Im checking if the itemstack return is empty
You could also just do that all in one operation
And then drop everything in the overflow map
Well, the issue with that is. You heard of EpicHoppers on Songoda? I trying to re-create that but not a full clone. I can download the plugin if I want to use it as I paid for it but the reason I started the farm rods is because EpicFarming adds items which turned into not realistic. You should not get a golden apple when you timber a tree like EpicTimber does
You can probably configure that
if anyone with worledit/fawe api experience could help me with this it would be great
I'm loading a schematic programatically
I want to know where the center is
the center being like the point that it pastes from
looking for a developer to replicate a game mode of sorts. DMs are open 🙂
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
yo
is it posible to make a plugin so u have an item, and when u right click, it gives u an effect and it has a cooldown
can some one help me with multy vurse core plugin? I want to know how I can make it so when some one joines for the first time they spawn in some tutorial place then when you do /spawn it takes you some were else but still have it in the same mv world?
yeah
create your item and give it a pdc tag, check if the item has said tag in the player interact event then do what you want
?learnjava to start with
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.
how can I detect if a player's attack was a critical hit
ok well
I just made a bunch of checks and this works ig
@SuppressWarnings("deprecation")
public boolean isCriticalHit(Player player) {
if (player.getFallDistance() <= 0) {
return false;
}
if (player.isOnGround()) {
return false;
}
if (player.isClimbing()) {
return false;
}
if (player.getLocation().getBlock().isLiquid()) {
return false;
}
if (player.getPotionEffect(PotionEffectType.BLINDNESS) != null || player.getPotionEffect(PotionEffectType.SLOW_FALLING) != null) {
return false;
}
if (player.getVehicle() != null) {
return false;
}
if (player.isSprinting()) {
return false;
}
if (player.getAttackCooldown() < 0.9) {
return false;
}
return true;
}
Hey, I made a plugin, but when I boot my server, I get this error:
[Server Thread/Error} Could not load 'plugins/MyPlugin.jar' in folder plugins
org.bukkit.plugin.invaliddescriptionexception: Invalid plugin.yml
Jar doesnt contain plugin.yml
I remember making all of that, what should I do?
Screenshot where you added the plugin.yml
I dont have embed perms. Its in the root directory
?img
Not verified? Upload screenshots here: https://prnt.sc/
@tall jacinth ^ Screenshot it and use this and just send the link
2 secs
plugin.yml is in the wrong location
It needs to be in the resources folder
src/main/resources
Should I use the originalplugin.jar or just the plugin.jar
plugin.jar. But you should've named the plugin jar in your build file
out of curiosity why should i be using ThreadLocalRandom.current().nextDouble() instead of Math.random()
Ok, thanks for the help! I got the plugin working, but ive coded everything wrong lol
Math.Random() is just find. Depends what you're doing I guess
Lol all good. Least you have it working. now just to fix up all your code
Yeah imma admit i got chatgpt to do it all cause i wanted to see how good chatgpt could code
but of course
it kindof works
ChatGPT isn't something you should rely on for writing everything. It's really only good for getting ideas on how something could be done. Even then it's not that great.
I use chatgpt when i wanna ask some obscure question that i prob wont be able to find online
Do you know any sites that can help?
The Spigot java docs for help with spigot api related stuff
?learnjava if you need help with java stuff
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.
?jd-s
has anyone tried to replicate crit particle effects from perfoming an actual critical hit before
I'm just trying to make some feature where a player can perform a critical hit without actually jumping
so I've multiplied the damage by 1.5 and played the crit sound effect
Just spawn the particles?
but getting the particles right is very tedious
yes but
I'm talking about
the exact x y and z offset
and speed
and the count
because right now my particles are just flying away from the mob and look a little spaced out
if that makes sense
its noticably different
just look at how nms does
You have to play with those yourself and find out what works for what you're trying to do
here are my parameters right now
world.spawnParticle(org.bukkit.Particle.CRIT, entity.getLocation(), 25, 0.3, 0.5, 0.3, 0.4);
How can i look through nms source code
mappings
just remap your stuff
and then it all just works
so unfortunately the regular sword crit stuff seems to be client-sided but we can just use arrows
arrows?
sorry what
oh your talking about the particle effect type
i already have that covered
isn't it just Particle.CRIT
no I mean they actually handle velocity here
velocity of what
perhaps the logic is the same, no?
depends on the particle
idk why im freaking out over this so much
arrows do like
world.spawnParticle(Particle.CRIT, entity.getLocation().add(0, 0.6, 0), 25, 0.4, 0.4, 0.4, 0.4);
this works fine enough and looks really close to the original
im just being too picky ig
4 particles where the first one starts at the arrow location and slowly trickles towards arrowLocation + speed
and they all have -speed as their speed
damage indicator particles are just
woah
wait can u send that line to me
wait but
is that really true
because when i crit a chicken
theres still like 20 particles
chickens have 4hp
maybe it has to do with your health
or maybe it's just the amount of damage you done
mhm
so thats how cancellable events owrk
with my fist
oh wait what
ok i just learned something
if you use a weapon
it spawns "magic crit" particles
as well as normal crit particles
y eah so
those are just packets
and the client handles all the logic
so you could have just sent packets
i could..
is it really worth it
ok wait incorrect
if you use a weapon
that has an enchantment on it
specifically sharpness
this is too confusing
or smite on undead, or bane of arthropods on arthopods
does FileConfiguration#addDefault(...) add the specified yml option if it isn't already present?
i want it to do it once and then let the user decide what to put there
how can i achieve this?
have a config.yml in src/main/resources, add your defaults add saveDefaultConfig to onEnable
but onEnable runs every time the plugin is loaded, wouldn't that re add the option even if it was removed?
i should've mentioned this earlier, i want to make a list that's going to receive some user input
ex:
coolname:
defaultOption:
- "something"
- "something2"
someUserInput:
- "cool hat"```
i want defaultOption to be added when the file is created, how can i do that?
saveDefaultConfig copies the one in the jar and won't overwrite
So it's fine for your purposes
ohhh alright, thank you very much, wasn't expecting an answer from you out of all people, ty ❤️
No matter what I do, I keep getting this error
Ive re written plugin.yml, and just cant figure it out
I know nothing is spelt wrong, ive done that multiple times
Show your path
Define path please
show plugin.yml and show your file tree
Right click to java folder and set sources root
should be near the bottom mark dir as
Test sources root?
does your project have a jdk
do you have a jdk installed
file -> project structure > top option, i dont remember its name
Why didnt create project using plugin?
not everyone uses it
I dont see project structure
something isnt adding up
the project structure should show if there was a jdk added
does control+alt+shift+s bring anything up
Nope
does the fact im using webstorm matter?
should i try with vs code
not many people here use vsc but any java ide works
LMAO
I think i know what I did wrong
Use IJ
shouldnt need to declare it, also i wouldnt use webstorm for java development, webstorm is more made for web stuff, js, cs, html etc etc
?paste it
Im still getting it even though I added the api
show what ur plugin.yml looks like now
change it to 1.17, doesnt need the patch version
why its only triggered when i click at block
do you run paper
Im still getting the same error i dont know wtf is happening
check the jars updated and restart again
yes
change ignoredCancelled = false to ignoredCancelled = true
they cancel the event when its not against a block
Do i need the 1.17 buildtools im guessing?
now it igonreCanceled, change it?
oh wait my brain did the backwards, change it to false not true lol
if you specify the repo you shouldnt need to, but running buildtools helps for the future
wtf just happened to the channel
?
I'm stuck with how to use sendMessage(). I've tried everything I could think of.
playerInstance.sendMessage("string")
oh wait my brain farted
its api-version not api

ok lol
ty
bru i gotta restart my whole server
java just shit itself and wont stop
use task manager lol
oh jsut press control c to stop the process
lmfao
Open another shell -> kill process
Altrough, just closing existing shell would end java process
SendMessage is crossed out when I tried that.
Paper is just 1/3 cut vanilla features for more players
they have a nice API though
Guys what this error mean?
😱
But don't just copy & paste your spigot plugins into paper plugins. If you want to use paper you should use it from the get-go and not be afraid of using it
MainCommandTreasureHunt.java:23
BRUH I USING PAPER TOO
?BRUh
Almost everyone uses paper
?whereami
whats MainCommandTreasureHunt.java line 23
ah
if (Files.isDirectory(Paths.get("plugins\\TreasureHunt\\"))) {
}
else{
try {
Bukkit.getLogger().info("[Treasurehunt] Created TreasureHunt Folder!");
Files.createDirectory(Paths.get("plugins\\TreasureHunt"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}```
which line specifically
} catch (IOException e) {
where is your Arrays#asList call?
eh
Also try recompiling
hm
Also use / in paths - not \\
uhh
it just see if there isn't a file called treasure hunt
Latter might not work
The first one always work
there's an internal replace call
File.separator / File.separatorChar
new File(plugin.getDataFolder(), "treasurehunt").mkdir()
b u t
eh
saveResource doesn't do the replace calls so use file.separator
I've had issues where testing worked in linux but caused issues on windows
if there is aready folder called that does it will wmake other folder or no?
Because on linux you can make use of \ so \\ is defo gonna brick on linux
Idk check it yourself
an instance of your plugin
JavaPlugin instance
the file?
no, an instance
Bruh he gonna say how to get instance
if you dont know what an instance is
dayum bro
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
yes
You cannot say taht
learn java before starting plugins
Use JavaPlugin.getPlugin(TreasureHunt.class)
I See
know basics no need know all of java
It's dumb af but I cannot be arsed to explain DI to you
the basics includes instances im guessing
maybe i can't remeber instances
An instance is an object
or just do ```
private static PluginName instance = this;
public static PluginName getInstance(){
return instance;
}
the easy answer is everytime you do new Class() that returns an instance, but sometimes you need to reuse that instance, javaplugin is that case, you then have to pass it about or use static getters
Not to be confused with the Object class
smth like that dont got my ide
fr
ew singleton
That won't work
Set static from onEnable
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
But still, Learn Java
Yea, dont got my IDE rn
You cannot assign this to a static
sure when i need to
how can create percentage drop from configuration
YOU NEED TO
You'd need to do that in the constructor
eh only basics
all that happens if you ask these basic questions is being told to learn java
You should know Java before you write a plugin
Math
or at least know the basics of programming
eh
... and you can only know java by programming stuff
i know but how do it
hm
I'll write a big post about static and overall static abuse and just reference it next time
you can learn the concepts before making anything
this what i was mean lol
you can learn java while coding
get fricked
rip
NOO MY STATIC ABUSE
Telling people to learn java instead of showing them boilerplate solutions that barely work will only reduce motivation
I cant figure out how to add a / command to my plugin, what should I do?
yeah you can, this is now the time to go learn something else
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Nope staying learnin java
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The wiki has a few decent snippets if u wanna find some stuff
what, im telling you that learning java while making plugins is fine, just when you encounter something new you dont know or dont understand it is the time to go and learn about that feature and how to use it
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.
ı
i should do a refresher course
:0 Good idea
spending an sfternoon on oracle.com ...
delet this now
like this? ```java
private TreasureHunt instance = this;
public TreasureHunt getInstance(){
return instance;
}```
you're ruining my immaculate search index
im gonna steal the idea from you but fine
fuck it
Create the Var instance, assign it in the onEnable() of ur plugin
Illusion Search Index - Static (aboose)
The concept of static in Java is quite simple when you get to it. To understand static we first must understand how Object Oriented Programming
works.
When creating a class, we're actually creating a structure that an object will follow. This structure defines
what variables are contained within the object, and how the implemented methods interact with such variables.
An object, in java, is created using the new keyword, which calls a constructor defined in the class. You create
a constructor to define some base logic that applies upon initialization of the object, such as the common design pattern
of Dependency/Constructor Injection.
When we talk about an instance of an Object, we're talking about the object as a whole, with its data included. Think of an
object as a box or package of information with a pre-defined structure that is set by the class. That structure indicates
how the data contained within the package behaves.
When passing around objects, with the exception of primitives (int, long, boolean), we're actually passing around a memory
reference to the object. Think of this memory reference as a tracking code, which is used in an internal map/dictionary to indicate
what data belongs to what address. This helps minimize the amount of memory used and is commonly refered to as "Pass by Reference".
Now, how does static come into play?
static is a keyword that indicates that the reference in question should be statically allocated. A statically allocated
object is permamently present in memory (ram), and can be accessible anywhere, at any given time.
By design, a statically allocated object will not be garbage collected, as it can still be accessible by any class at any given
time, even from other static objects or methods. With such a choice, it is exclusively meant for constants, and should also be used
by utility classes.
The only non-constant allowed use of static is in Singletons, which are basically a single constant instance, but are lazily initialized.
TL;DR - Valid usage in:
- Constants
- Utility classes
- Singletons (when DI is impossible)
Examples
Here is an example of a utility class, with a constant
public final class MyUtilityClass { // final to prevent inheritance
private static final int NUMBER_OFFSET = 100; // constant value, permanent
private MyUtilityClass() { // Private constructor to prevent initialization
}
public static int offsetNumber(int original) {
return NUMBER_OFFSET + original;
}
}
Here is an example of a lazy singleton (lazy means it is only initialized when needed)
public class MySingleton {
private static MySingleton INSTANCE = null;
public static MySingleton getInstance() {
if(INSTANCE == null) {
INSTANCE = new MySingleton();
}
return INSTANCE;
}
private MySingleton() { // prevent external initialization
// optional: check for duplicate instances
if(INSTANCE != null) {
throw new IllegalStateException("Duplicate instance");
}
}
private int currentNumber = 0;
public int getOffsetNumber() {
return MyUtilityClass.offsetNumber(currentNumber++);
}
}
Here is what NOT to do:
public class Circus {
private static PlayerManager playerManager;
private static SomeOtherManager someOtherManager;
private static String status = "broke";
private static int money = -1;
public static PlayerManager getPlayerManager() {
return playerManager;
}
public static int getMoney() {
return money;
}
public static String getStatus() {
return status;
}
public static SomeOtherManager getSomeOtherManager() {
return someOtherManager;
}
}
(separate message due to character limit)
How can I pass data around without static?
Through Dependency/Constructor Injection (DI). (https://www.spigotmc.org/wiki/using-dependency-injection/)
By passing our data through the object's constructor, we can avoid the use of static and any kind of singleton patterns. Here's a basic example:
public class ExampleListener implements Listener {
private final ExamplePlugin plugin;
public ExampleListener(ExamplePlugin plugin) {
this.plugin = plugin;
}
...
}
And to instantiate it (within our plugin class):
new ExampleListener(this);
Why is the misuse of static bad?
Java is inherently an Object Oriented Programming language (OOP), and its main gimmick is the ability to work with objects. By abusing static, you're breaking the core principle that makes java such a suitable language general use, as well as introducing new issues such as memory leaks (Pro tip: It's never good to mess with mutable data in a static context!) and making your code harder to maintain. Static abuse is one of the easiest ways to introduce tech debt to a project.
Avoid static if you don't understand it. Most often than not you'd end up abusing**
sure
noo my immaculate record
mustve been the wind 💨
Thank for help anwyay
If you want me to, ill throw up a few boiler plate repos with a bit of code so you can see how it works!
wait like this>? java public void onEnable() { public TreasureHunt getInstance(){ return instance; }
how you
no
Nooo
put 2 plulic void
instance =this
public void onEnable() { TreasureHunt instance = this;
@Override public void onEnable() { TreasureHunt instance = this; Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!"); this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt()); this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt()); new File(instance.getDataFolder(), "Treasurehunt").mkdir();
this should work
private TreasureHunt instance;
public void onEnable(){
instance = this;
}
public static TresureHunt getInstance(){
return instance;
}
private static TreasureHunt instance;
@Override
public void onEnable() {
instance = this;
}
public static TreasureHunt getInstance() {
return instance;
}
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
oh pog 😄
public final class TreasureHunt extends JavaPlugin {
private TreasureHunt instance = this;
public TreasureHunt getInstance(){
return instance;
}
@Override
public void onEnable() {
instance = this;
Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
new File(instance.getDataFolder(), "Treasurehunt").mkdir();
}```
It need to be private static TreasureHunt
ah
and remove the = this on iit
in both instance and getInstance
it give me error
And yeah, remove the instance = this
sure
public final class TreasureHunt extends JavaPlugin {
private static TreasureHunt instance;
public TreasureHunt getInstance(){
return instance;
}
@Override
public void onEnable() {
instance = this;
Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
new File(instance.getDataFolder(), "Treasurehunt").mkdir();
}```
yep
i just did that
hope it works
so like it create instance and set it to this class
ig?
it has an instance variable, on startup it asigns it then you can access it with TreasureHunt.getInstance()
eh other error]
did i do anything wroung here?
public final class TreasureHunt extends JavaPlugin {
private static TreasureHunt instance;
public TreasureHunt getInstance(){
return instance;
}
@Override
public void onEnable() {
instance = this;
Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
new File(instance.getDataFolder(), "Treasurehunt").mkdir();
}```
it fine ig
nothing wrong
but it give me this error java.lang.ExceptionInInitializerError: null at org.treasurehunt.untitled.TreasureHunt.onEnable(TreasureHunt.java:20) ~[Treasurehunt.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-307] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:422) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-307] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307] at java.lang.Thread.run(Unknown Source) ~[?:?] Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Unknown Source) ~[?:?] at java.util.Arrays$ArrayList.<init>(Unknown Source) ~[?:?] at java.util.Arrays.asList(Unknown Source) ~[?:?] at org.treasurehunt.untitled.MainCommandTreasureHunt.<clinit>(MainCommandTreasureHunt.java:23) ~[Treasurehunt.jar:?] ... 12 more
eh
if you only need to check if the datafolder is there just mkdirs it on onEnable
bc thats all the old code did
no old code here ```java
package org.treasurehunt.untitled;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public final class TreasureHunt extends JavaPlugin {
private static TreasureHunt instance;
public TreasureHunt getInstance(){
return instance;
}
@Override
public void onEnable() {
instance = this;
Bukkit.getLogger().info("[Treasurehunt] The Plugin Is Ready!");
this.getCommand("treasurehunt").setExecutor(new MainCommandTreasureHunt());
this.getCommand("treasurehunt").setTabCompleter(new MainCommandTreasureHunt());
new File(instance.getDataFolder(), "Treasurehunt").mkdir();
}
@Override
public void onDisable() {
Bukkit.getLogger().info("[Treasurehunt] The Plugin Just ShutDown!");
}
}```
and i dowload the plugin
its in MainCommandTreasureHunt
let me check again
that is the old code
yessir
so remove it
yeah
sorry what problem again in MainCommandTreasureHunt
this code
okay then whats line 23 in MainCommandTreasurehunt
when the plguin enable it was should run this
static ArrayList<String> names = new ArrayList<String>(Arrays.asList(f.list()));
deleted
ah
use descriptive var names
i was just testing smth
and i forget remove it
i thought it wasn't make any error
but it did
so i don't need it anwyay
you also shouldnt make a list like that
it will not function anyway it was test
it was list of files
in treasurehunt folder
then get the name of this file
and add it to tabcomplete
FUCK
but it not working
you are making my brain hurt
fr
but this the pain of teach new people ¯_(ツ)_/¯
Im bak what broke?
lost like 10 minutes of writing
rrip
RIP
my brain
rip
Normal Tuesday
real
ah man it won't be the same
@remote swallow Should the code here make folder called Treasurehunt
@karmic salmon Here just pushed a boilerplate
https://github.com/Bedlesssgod/InstanceExample
Just checking bec when i reload it made nothing 💀
it should make a folder in plugins/TreasureHunt/Treasurehunt
rip paper
wdym rip paper?
bruh why 2 Treasurehunt
that repo doesnt exist
no i was it should make folder in Treasurehunt
bc thats your code
remove that line and add getDataFolder().mkdirs()
repo is private
can some one help me with multy vurse core plugin? I want to know how I can make it so when some one joines for the first time they spawn in some tutorial place then when you do /spawn it takes you some were else but still have it in the same mv world?
? new File(instance.getDataFolder().mkdir());
no need
There a function
you dont need the instance either