#help-archived
1 messages · Page 222 of 1
I mean it should say which plugin is throwing the npe
anyone know a good anticheat like spartan but free
becus i am poor boi
does anyone know how to help with missing item display names on items? I heard it might be due to some weird new limit thingy
What
I believe most good anticheats are paid resources due to the amount of effort that goes into coding them.
it does
I looked at the code and it looks fine
but the team is null for some reason
I mean you can try the good old one at a time method
bruh
@balmy sentinel what would i do to put an item in it?
inv.setItem(int, ItemStack);
would that be an item id or name
wdym?
inv.setItem(1, Stone);
No, you have to create an ItemStack (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ItemStack.html)
config.yml:
Example:
Example1: Value1
Example2: Value2
How can I read this as a Map<String, String> in Java through FileConfiguration?
ConfigurationSection#getValues()
(JavaPlugin#getConfig() is an instance of ConfigurationSection too)
Ok thanks I'll try
But #getValues only takes a boolean deep as a argument
Can I not get the subtree of a variable I already know?
Actually nvm
Yeah, just getConfigurationSection(String) to get that Example path, call on it getValues()
Oh
so... since we're on the topic of itemstack.. does anyone know anything about this apparent display name limitation in 1.16.1 spigot
getConfig().getConfigurationSection("Example").getValues(false) for instance would give you a Map<String, Object> of Example1:Value1 and Example2:Value2
@balmy sentinel I am confused i have only made simple commands in java could you send me what i need to make an item show up in the gui?
ItemStack stack = new ItemStack(Material.STONE);
inv.setItem(0, stack);
If you want to change the display name, add enchants, etc. you'll need to get the ItemMeta and mess with that, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/ItemMeta.html
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
*You don’t actually need meta for enchants
oh fuck right. You can change ItemFlags with meta
I am struggling to find the ones for lure and name @balmy sentinel
wdym like you’re trying to create lures and a name for it?
yes
^^^
is it meda block data
void setDisplayName();
i have imported org.bukkit.inventory.meta.ItemMeta but it still does not like meta.setDisplayName(“My CustomName”);
?paste
what does your method look like rn
because you never created an ItemMeta object
also after you change the ItemMeta it won't take effect until you #setItemMeta(meta)
like this?
ItemMeta meta = new ItemMeta() {
@Override
public void setDisplayName(String name) {
}
does this work? related to the border-thing
It should
alright
@balmy sentinel I have this But it is not renaming a the stone
ItemStack stack = new ItemStack(Material.STONE);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.RED + "Hi");
inv.setItem(0, stack);
also after you change the ItemMeta it won't take effect until you #setItemMeta(meta)
lol thanks Coll
Why is it that all of these plugins that have been submitted after mine have been approved, but mine has not? It's been driving me crazy waiting.
stack.setItemMeta(meta);```
Mine is ~40kb not including Hikari, so I doubt that would be bigger than a Factions plugin
If you obfuscated your code it'll take longer to approve as well.
Nah, chose not to obfuscate for the first release for that exact reason lol
Yeah, planning to go OS at some point anyways
?paste
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
create a list, add to that list, meta.setLore(listName);
add a ChatColor.RESET in there or something or else you'll get that ugly purple + italics lore.
why the hell doesnt my spawn prot. work?
looks right:
@EventHandler
public void blockPlace(BlockPlaceEvent event) {
Location spawn = new Location(Bukkit.getWorld("world"), 1770.000, 68, -558.500);
Location loc = event.getBlock().getLocation();
if (spawn.distance(loc) < 30) {
event.setCancelled(true);
}
}```
IllegalArgumentException - for differing worlds add a check maybe.
Also distanceSquared is faster
Right world?
@lone fog yes
Register event?
@lone fog yes
the event gets called... it stops at the cancel...
if (spawn.distance(loc) < 30) { is true, but it cant get cancelled...
What
i dont get it... wtf
I guess you can try a higher event priority
sending a message works... but cancelling the event doesnt...
Maybe another plugin is un-cancelling it
sounds like developing tbh
i know but wtf
doesn't work 1 sec works the next
thats the job description.
trying to pull a block out of my config. But it does not work my code is:
ItemStack stack = new ItemStack(Material.Reason_1_block);
String Reason_1_block = getConfig().getString("First_Reason_block");
@balmy sentinel
uhh I've never tried doing this before, but I don't think the way you're thinking about this will work logically speaking.
You could try this, https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html#matchMaterial(java.lang.String)
declaration: package: org.bukkit, enum: Material
and you'll need to null check as well.
declaration: package: org.bukkit, enum: Material
Material.fromString
Does not work
ItemStack stack = new ItemStack(Material.valueOf(getConfig().getString("First_Reason_block")))
Ah yeah it’s getMaterial
Not from string
Won’t throw an exception like value of
But you still need to null check
could just do a try and check for both IllegalArgumentException and NullPointerException.
I think the only time I ever use try/catch is with my database
Can be useful with parseInt too
Although I think you can technically check it with regex
I usually have an UtilInteger class in big projects where I just do a check quickly
Ah yeah you can also loop and check each char
@lone fog That did not work
"that did not work" doesn't really tell us anything. What are you trying to do, what errors are you getting, etc.
org.bukkit.command.CommandException: Unhandled exception executing command 'punish' in plugin Ban_Gui v1.0-SNAPSHOT
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.15.2.jar:git-Paper-350]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.15.2.jar:git-Paper-350]
at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:761) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1861) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1669) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.15.2.jar:git-Paper-350] at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:1105) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:1098) ~[patched_1.15.2.jar:git-Paper-350]
at
net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:1059) ~[patched_1.15.2.jar:git-Paper-350]
at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:974) ~[patched_1.15.2.jar:git-Paper-350]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
Caused by: java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.Material.stone
at java.lang.Enum.valueOf(Unknown Source) ~[?:1.8.0_251]
at org.bukkit.Material.valueOf(Material.java:85) ~[patched_1.15.2.jar:git-Paper-350]
at me.dash.pl.Pl.myInv(Pl.java:40) ~[?:?]
at me.dash.pl.Pl.onCommand(Pl.java:60) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.15.2.jar:git-Paper-350]
... 17 more
No enum constant org.bukkit.Material.Material.stone
Upper case it
what does your config.yml look like @ionic hound ?
First_Reason_block: 'Stone'
First_Reason: 'Ping Spoofing'
First_Reason_lore: 'This fakes lag.'
capitalize it like Coll suggested.
still get this No enum constant org.bukkit.Material.Stone
ow shit you have to do STONE not Stone
String#toUpperCase
The string must match exactly an identifier used to declare an enum constant in this type.
[19:33:11 WARN]: Event ServerConnectEvent(player=iiAhmedYT, target=BungeeServerInfo(name=lobby1, socketAddress=/0.0.0.0:25560, restricted=false), reason=PLUGIN, request=net.md_5.bungee.api.ServerConnectRequest@b400653, cancelled=false) took 326ms to process! im getting this error alot idk what is going on?
does it mean by a plugin
a spigot one
or a Bungee one
?
Hello! Can I use a string data (in .yml file) to define an ItemStack type?
@lofty meadow if you’re talking about defining a Material then yes. If you read above you can figure out how it’s done.
Ohh
Itemstacks are serializable aren’t they? (If you need more than just a material)
Yes, ok!
@hardy cedar I don’t know much about bungee so I can’t help you as to why you’re getting the warning, but that’s a warning not an error.
You can probably use .valueOf
🤔
Or you can serialize an entire item stack
Can you example me a bit?
Enchantment.getByKey
Make a namespaced key from your plugin instance and the string in the config
Actually not your plugin instance
I assume it uses NamespacedKey.minecraft
Is this right?
NamespacedKey namespacedKey = new NamespacedKey(this.plugin, "PROTECTION_ENVIRONMENT");
Enchantment enchantment = Enchantment.getByKey(namespacedKey);```
Ok!
I assume it uses NamespacedKey.minecraft
when i put my start.bat file it doesnt turn into a terminal
hi
does anyone know any way around the weird spigot 1.16.1 item display name limiter?
What limiter
Is this not correct? Console says it's an unknown command ```
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "lpb user " + sender + " setprefix 10 " + args[0] + " ");
Hi, so not sure if this is where I should be posting this but I need a plugin that will keep players from taking items out of there head slots. I am made a hat panel with command panels that allows you to add a hat to your head. It is a block. But players are able to duplicate blocks with this. Any way of preventing them from taking the block off there head? Anyone that can make a plugin or anyone know of a plugin like that?
@marsh hawk and @wispy pewter thank you both for helping me a couple days ago. finally figured out my problem and it was just that the server version was too new for my old JDK. so i updated to JDK 14
@leaden coyote go on the forums and go under Services and Recruitment.
Ahaha that happens
No worries 🙂
!q test
Hi, so not sure if this is where I should be posting this but I need a plugin that will keep players from taking items out of there head slots. I am made a hat panel with command panels that allows you to add a hat to your head. It is a block. But players are able to duplicate blocks with this. Any way of preventing them from taking the block off there head? Anyone that can make a plugin or anyone know of a plugin like that?
@leaden coyote
You can cancel the event if they drag an item out of a slot: (in this case instead of canceling the off hand slot cancel the slot for the head)
where is that bot lol
@pastel condor im not a coder...
How do I include args in a Console dispatchCommand?
it's not a bot; it's just fierceeo typing really fast
😑
how long did it take to make btw?
I mean if you want to see your yourself, I can send you the invite link.....
how long did it take to make btw?
@marsh hawk
Like a day
Lol yeah
I’m going to collect data from some more servers and I’ll try to improve my question algorithm to get more revenant results
is it actual machine learning or just matching search terms?
It just matches words
In the future if I have a big enough database I want to make it actually learn
yeah that would be awesome
Yeah 🙂
I've always wanted to start learning ML just don't have any relevant usecases
Lol
Well I mean if you want to help me, idk
Anyways
The bot hasn’t finished going through the spigot message history
It still has a long way to go
how exactly are you caching all the data?
I’m using something called map db
It doesn’t load the map entirely on the disk
*ram disk
Which makes it really nice
oh thats awesome
what are you querying? I assume most keyword matches?
Yes, I see how many words match in the query and in a question
Though when my database gets bigger I need to find a faster way
Maybe partition into topic groups?
back
I mean I could add you to the repo 🙂
that would be awesome
whats your github username?
Lickymoo
okay cool one sec
I kinda stuffed everything in to two classes which I really need to fix
but
anyways
eh it works lol
okay just added you
How do i get to the spigot doc for 1.8.8 (yea i know the server is outdated af, but lots of servers are thanks to the combat update. Plz don't judge lol I'm just the developer)
Looking thru the docs I'm guessing most of the deprecated methods are pre-1.8 or pre-1.13 or whatever lol
Is it possible to make a anti cheat using plugins?
Whats a good land claiming plugin for survival servers?
plotsquared v5
What are some great open source plugins to learn from
do i need a start.bat for setting up a spigot server?
because once i had the spigot.jar in a folder i just ran it and accepted the eula
the start.bat never runs properly
it doesnt change into a .bat folder from a notebook folder
You probably saved it as start.bat.txt
how do i fix it?
Change the ending from .txt to .bat?
We litterally told you how to fix it yesterday
What exactly doesnt work?
What you need to do is delete InventoryMove and onInventoryClick
He has events to cancel item movements but he doesn't want them to be cancelled
That's the issue
"It's stuck in te 9th slot" I did read...
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.getCurrentItem().isSimilar(netherStar)){
event.setCancelled(true);
}
}
that's why my good sir
"its stuck" implies that you want it to move. But i get your point.
do a playerinteractevent
Alright fine
if the item hashcode is equal to the netherstar item hashcode
I told you that yesterday too
^
InventoryClickEvent -> if netherstar -> open GUI
PlayerInteractEvent -> if nether star in hand -> open GUI
Yeah if you just do that it will work
next time instead of yelling and screaming no when we're trying to help, maybe actually remove the first bit
i know this is probably very basic but i cant figure out how to get this to work
if (!(new File(this.getDataFolder(), "monsters").exists())){
this.saveResource("monsters", false);
}
I'm just trying to save the folder "monsters" to my plugin directory, it works with all yml files but not folders, am I forgetting something to put in the path?
or do you have loop through every file in the folder and save every one individually
I don't think you can save a folder like that
i think it'd be best to just create the folder probably manually then saving the resource? but you might just have to put a /
at the end
Try getting it's contents ^
7smile7 big brains to the rescue 😎
I was really hoping you could just save folders like that but i guess thats not the case lol
So 2 things. new File(this.getDataFolder(), "monsters") is actually a flat File and not a folder
new File(this.getDataFolder() + File.separator + "monsters") will be a new folder
With the spigot API its not possible to save a complete folder. You can however traverse a jar file like every other file system.
If you give me a min ill show you how.
that'd be really nice of you thank you
public void copyResourceDirectory(final JarFile source, final String path, final File target) throws IOException {
final Enumeration<JarEntry> entries = source.entries();
final String newPath = String.format("%s/", path);
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (entry.getName().startsWith(newPath) && !entry.isDirectory()) {
final File dest = new File(target, entry.getName().substring(newPath.length()));
final File parent = dest.getParentFile();
if (parent != null) {
parent.mkdirs();
}
this.writeToFile(source.getInputStream(entry), dest);
}
}
}
This will save a whole path from a jar to another file system (in your case just flat files)
You just need to write the writeToFile method
basically just a writeToFile(final InputStream input, final File target)
private void writeToFile(final InputStream input, final File target) throws IOException {
final OutputStream output = Files.newOutputStream(target.toPath());
final byte[] buffer = new byte[ResourceCopy.BUFFER_SIZE];
int length = input.read(buffer);
while (length > 0) {
output.write(buffer, 0, length);
length = input.read(buffer);
}
input.close();
output.close();
}
This would be an example with a buffered reader -> outputstream
will this also work if the folder constains several subfolders with subfolders with those containing the files
Just ask here and we might answer
for ( i=0 ; i<4 ; i++){
printf("Enter Number%d student's information:\n",i+1);
printf("Enter name:");
scanf("%c\n",s[i].name);
printf("Enter Math Mark:");
scanf("%d\n",&s[i].mathMarks);
printf("Enter Science Mark:");
scanf("%d\n",&s[i].scienceMarks);
printf("Enter Art Mark:");
scanf("%d\n",&s[i].artMarks);
}
it messes up
sec
once we type the name
it spams the rest
No this wont work with sub folders. You would need to add a recursion to the method.
we need the answe in 25 mins
pls
sorry not tryna be rude
but
its quite urgent
almost like a now or never
You need to wait before sending the next scan
ok
Wait until someone enters a value
how do we wait
i thought so
i thought by default
it waits
like in cpp
it pauses the main thread
not so in c?
how do we pause the main thread until someone enters a value
It should wait with scanf
ok ive fixed it
#include <stdio.h>
struct student {
char firstName[50];
int mathMarks, scienceMarks, artMarks, roll;
} s[10];
int main() {
int i;
printf("Enter information of students:\n");
// storing information
for (i = 0; i < 5; ++i) {
s[i].roll = i + 1;
printf("\nEnter Number%d student's information,\n", s[i].roll);
printf("Enter first name: ");
scanf("%s", s[i].firstName);
printf("Enter Math marks: ");
scanf("%d", &s[i].mathMarks);
printf("Enter Science marks: ");
scanf("%d", &s[i].scienceMarks);
printf("Enter Art marks: ");
scanf("%d", &s[i].artMarks);
}
}
#include <stdio.h>
#include <stdlib.h>
struct student {
char name[20];
int marks[3];
} students[4];
typedef struct student Student;
int main() {
for (int i = 0; i < 3; i++) {
printf("Enter student name\n");
scanf("%s\n", students[i].name);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[0]);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[1]);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[2]);
}
}
@frigid ember
Someone knows a plugin with fly feature and supporting MySQL?
(Example: Hypixel, because why not)
ok i am back with the nether star thing,
public void NetherGUI(PlayerInteractEvent event) { if (event.getItem() != null && event.getItem().isSimilar(netherStar)) { new NetherStarMenu().openInventory(event.getPlayer()); } }``` i did this but when i click the nether star it doesn't work...
@frigid ember @mellow wave
do i actually have to make a trigger for it to open
because i think i only defined it
How do you click it? in inventory
#include <stdio.h>
#include <stdlib.h>
struct student {
char name[20];
int marks[3];
} students[4];
typedef struct student Student;
void sumStudent(Student *st, int *dest) {
int sum = 0;
for (int i = 0; i < 4; i++) {
sum += st->marks[i];
}
*dest = sum;
}
int main() {
for (int i = 0; i < 4; i++) {
printf("Enter student name\n");
scanf("%s", students[i].name);
printf("Enter math mark\n");
scanf("%d", &students[i].marks[0]);
printf("Enter math mark\n");
scanf("%d", &students[i].marks[1]);
printf("Enter math mark\n");
scanf("%d", &students[i].marks[2]);
}
int sum;
for (int i = 0; i < 4; i++) {
sumStudent(&students[i], &sum);
printf("Student nr %d sum: %d", i, sum);
}
}
@frigid ember
Probably won't
@grim halo didnt work
What didnt work?
can someone tell me why that c student needs help with basic syntax 👀
i cant turn a start.bat
Save it as a bat file not a txt file
#include <stdio.h>
#include <stdlib.h>
struct student {
char name[20];
int marks[3];
} students[4];
typedef struct student Student;
void sumStudent(Student *st, int *dest) {
int sum = 0;
for (int i = 0; i < 4; i++) {
sum += st->marks[i];
}
*dest = sum;
}
int main() {
for (int i = 0; i < 4; i++) {
printf("Enter student name\n");
scanf("%s\n", students[i].name);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[0]);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[1]);
printf("Enter math mark\n");
scanf("%d\n", &students[i].marks[2]);
}
int sum;
for (int i = 0; i < 4; i++) {
sumStudent(&students[i], &sum);
printf("Student nr %d sum: %d", i, sum);
}
}
@frigid ember
the calcs are wrong
als you can remove \n from the scanf
It's recommended for them to be there since it's in a loop
Just found that while doing some research earlier
Uhhhhhhhhhh, isn't this #help-archived for Spigot?
It's #help-archived for help
"Serious Spigot and BungeeCord Help"
#include <stdio.h>
#include <stdlib.h>
struct student {
char name[20];
int marks[3];
} students[4];
typedef struct student Student;
int sumStudent(Student *st) {
int sum = 0;
for (int i = 0; i < 4; i++) {
sum += st->marks[i];
}
return sum;
}
int main() {
for (int i = 0; i < 4; i++) {
printf("Enter student name\n");
scanf("%s", students[i].name);
printf("Enter math mark\n");
scanf("%d", &students[i].marks[0]);
printf("Enter ir mark\n");
scanf("%d", &students[i].marks[1]);
printf("Enter kon mark\n");
scanf("%d", &students[i].marks[2]);
}
for (int i = 0; i < 4; i++) {
printf("Student nr %d sum: %d\n", i, sumStudent(&students[i]));
}
}
This is easier
Not that fancy pointer thing but it works
to get a start.bat i moved it from a diff pc
i got this message now:
whenever i try to run
cant see that file
the ss?
Bro just use Rust
Oh! and in sumStudent its i < 3 not i < 4
Rust is too immature to be used.
^
also why cant i just create a start.bat
is it because its not finding a spigot.jar?
uh
so it has nothing to actually start?
oh good lord
how do i enable it ;-;
yeah I think so
fml
Typh00n, a few things: 1. You can use 4G in place of "4000M" 2. 4 GiB is 4096 MiB, not 4000
at the top of file explorer
click view
and enable file name extensions
or smthn
that thing on the right
and then u'll prolly see ur jar file is named spigot.jar.jar
uh\
?
did u rename the spigot jar file?
i cant
i didsnt get option to
yeah then just rename it to spigot
and it should normally start up
also change "4000M" to either 4096M or 4G
Why are you forcing him to change it?
sorry i didnt mean to sound forceful but i'm just saying
lol
because 4000M is 3.9 gigs
and?
Actually, 4000 MB is 4 GB.
"attacking"?
No, I want him to change it as well, but 4000 MB is 4 GB.
you literally
AsdewToday at 2:34 AM
Typh00n, a few things: 1. You can use 4G in place of "4000M" 2. 4 GiB is 4096 MiB, not 4000```
homie
lol
not directed at you typh
was talking to asdew
sorry i don't say GiB i say GB lol because im ✨ uncultured ✨
doesnt matter use 4000M of 4G its almost the same
It's good practice to use 4 GiB, not 4000 M(i)B.
btw GiB and GB are totally different units
yeah uh i just reference them the same because i am ✨uncultured ✨
MB = * 1000
MiB = * 1024
KiB, MiB, GiB, and TiB are the ones that should always be used.
i can run my servers using the spigot.jar folder
wym typh
by executing it right? i did that before i fixed the issue with the .jar
wdym
it would work fine and id just connect by localhost
run multiple servers using the same spigot.jar?
You cant execute a folder
nonono
yeah uh you can't execute a folder xd
just double click the jar (if it is a testserver on windows)
like smile says
yes
could i copy/paste the spigot.jar onto my desktop so i can just run it at the click of a button
you could double click the jar if you have a version that supports the vanilla gui.
Most versions (i think prior to 1.15) ar headless
but if i recall it doesnt start with a gui?
i don't want to be annoying but why does this not work:
public void NetherGUI(PlayerInteractEvent event) {
if (event.getItem() != null && event.getItem().isSimilar(netherStar)) {
new NetherStarMenu().openInventory(event.getPlayer());
}
}
``` whenever i click on the nether star @grim halo
it does
oh
the start.bat doesnt
double click the jar -> console opens up
its just console ye
@frigid ember elaborate
so
@ebon girder i believe then the files of the server will be spread out on your desktop
unless you have it inside of a folder
i do
i had my blastercraft server
@frigid ember add a sysout on the top of the method and one inside your if clause. Then tell us how far the code went
@frigid ember rename your method
also, you registered the event?
and the .jar as a copy on my desktop
sysout?
wouldn't make a copy of it i think it's a shortcut i believe?
you mean
System.out.println() palm i believe
why tho?
they want you to print a line at the top of the method
to check if the method gets invoked
to see if the event fires
its the "spigot way of debugging"
on top to see if the event fires, in the if statement to see if the if statement is true
also
uh
i believe event.getItem()
returns Item ?
or does it return ItemStack
i forget
so just above the NetherGUI?
The ItemStack in the hand
in the event
so lie this
public void NetherGUI(PlayerInteractEvent event) {
if (event.getItem() != null && event.getItem().isSimilar(netherStar)) {
System.out.println("working");
new NetherStarMenu().openInventory(event.getPlayer());
}
}```
@EventHandler
public void NetherGUI(PlayerInteractEvent event) {
System.out.println("PlayerInteractEvent fired");
if (event.getItem() != null && event.getItem().isSimilar(netherStar)) {
System.out.println("Item is not null and the item is the netherstar");
new NetherStarMenu().openInventory(event.getPlayer());
}
}```
mk
you registered the event
also you're making a new instance of netherstarmenu everytime lol
that's not the best way to do it because then bukkit creates an inventory for it everytime
i think that's how it works?
store the class as a variable, perhaps in your main class
`
one sec
in your main class at the top before the @Overrides and stuff
public NetherStarMenu netherStarMenu;```
or you can do private
whichever
in onEnable
netherStarMenu = new NetherStarMenu();
and then make a method or you can just reference the variable when your reference the class
public void onPlayerAnvil(InventoryClickEvent event){
List<String> wordblacklist = getConfig().getStringList("BannedWords");
for (String blacklistedItem : wordblacklist) {
if (event.getCurrentItem().getItemMeta().getDisplayName().toLowerCase().contains(blacklistedItem)) {
int blockedcount = getConfig().getInt("WordsBlocked") + 1;
getConfig().set("WordsBlocked", blockedcount);
saveConfig();
String hiddenword = blacklistedItem.toLowerCase().substring(0, 1);
if (getConfig().getBoolean("HideFirstLetter") == true) {
hiddenword = getConfig().getString("HideWordSymbol");
}
for (int n = blacklistedItem.length() - 1; n > 0; --n) {
hiddenword = String.valueOf(hiddenword) + getConfig().getString("HideWordSymbol");
}
String oldmessage = event.getCurrentItem().getItemMeta().getDisplayName().toLowerCase();
event.getCurrentItem().getItemMeta().setDisplayName(oldmessage.replaceAll(blacklistedItem.toLowerCase(), hiddenword));
}
}
}```
I have error on this code
public NetherStarMenu getNetherStarMenu()
{
return netherStarMenu;
}```
what's the error welcome?
what's line 148
if (event.getCurrentItem().getItemMeta().getDisplayName().toLowerCase().contains(blacklistedItem)) {
You're using a null value on 148
ok
and if the item's item meta is not null
Also check if the item has a display name
ok
public NetherStarMenu getNetherStarMenu() { return netherStarMenu; }```
@bronze acorn you mean
{
return getNetherStarMenu();
}```
if (e.getCurrentItem().getItemMeta().hasDisplayName()) {
if (event.getCurrentItem() == null)
{
return;
}
if (event.getCurrentItem().getItemMeta() == null)
{
return;
}
if (event.getCurrentItem().getItemMeta().getDisplayName().isEmpty())
{
return;
}```
i believe
no @frigid ember
mk?
return netherStarMenu;
Someone knows a plugin with fly feature and supporting MySQL?
(Example: Hypixel, because why not)
now that one
Now this error occurs on line 157
if (event.getCurrentItem().getItemMeta().getDisplayName().isEmpty())
welcome
That line has an error
.hasDisplayName()
use hasDisplayName();
oh there's a hasdisplayname oop-
lol
also palm if you're using intellij right click the main class and click reformat code
make sure everything is unchecked
and click ok
lol
Now error occurs on line 161
if (event.getCurrentItem().getItemMeta().getDisplayName().toLowerCase().contains(blacklistedItem)) {
i have a small question. What is the best way to integrate a update checker on first release? As far as i know i need to provide a file when creating a resource.
yes
Same
for (String blacklistedItem : wordblacklist) {```
yes
is there a stringlist
specifically called
BannedWords
all it'd be is
BannedWords:
- word1
- word2
tah any solution
?
i have a small question. What is the best way to integrate a update checker on first release? As far as i know i need to provide a file when creating a resource.(Bearbeitet)
and remove that getNetherStarMenu() from your listener
sorry piston never made an auto updater 😭
oh ok
its really easy
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
its just a class
and creating a object in the main class
done now can i change it to final?
i am making a player stats to web plugin. Which category should it be?
Is it a plugin or standalone
An error occurs if it doesnt have a name
a plugin
i'd say use spring boot for that
.hasDisplayName() doesnt work
which hosts a webserver
look into spring boot
@copper star Send your updated code
ok
you'd need to make a Get request for it
i just wanna know what resource category it is
oh idk
This is the code
its just a handler
if (!event.getCurrentItem().getItemMeta().hasDisplayName())
{
return;
}```
DRY
Ok the error is gone
He didn't have ! Pistonmaster
um
taahanis told him to add it
Please welcome, have consistent indentations
The word is not getting filtered
was out of context
And did the debugg message send
Script?
Why is the name of the item not getting filtered
lemme check rn
Methods start with non capitalized characters palm
> [12:07:31 INFO]: PlayerInteractEvent fired
> [12:07:31 INFO]: PlayerInteractEvent fired
> [12:07:31 INFO]: PlayerInteractEvent fired```
And you’re doing some very weird logic
Also you do know that you will make all capitalized characters lowercase Welcome
Use hasItem instead of null checking it
I logged it and it works
event.getCurrentItem().getItemMeta().setDisplayName(oldmessage.replaceAll(blacklistedItem.toLowerCase(), hiddenword));
This line doesnt work
Welcome what are you doing?
so if(event.hasItem(netherStar) { }
Making item names filter
Please make references instead of invoking getItemMeta 4 times in a row
Yeah that code is a mess
No palm
oof
PlayerInteractEvent#hasItem checks if an item is involved
so if (event.getItem() != hasItem() && event.getItem().isSimilar(netherStar)) ?
:_:
main class
Wth palm, does creating a GUI with 6 slots work?
idk
and call the getNetherStatMenu
It doesn't
Star
i thought that meant 6 rows
o
inventories can only be multiples of 9 up to 54
but each slots number is one less ex. the first slot in a gui is 0
Unless you have your own fork and made everything up to work with 6 slots don’t use 6 👌
can it be because of that?
Pretty much I’d say
Interessting mod I would use that
Lol
also because ur making a new reference to the class still
call ur plugins class and reference getNetherStarMenu()
If it's not null, then what's the value when the hand is empty?
Material.AIR prolly ?
oh
Air for the win lol
how do i call it?
Item name now filters
whats ur main class name
thx for help
Main.getPlugin(Main.class).getNetherStarMenu().openInventory(player);
Palm he means that you should have 1 menu instance stored in your main and then you call it from there so you don’t create a new one every other time
hm
And don’t use that
mk
Go for dependency injection
yeah its not recommended
would a static main work?
Wym
a static variable that references ur main class is fine
ok
i usually do a private static variable
public void NetherGUI(PlayerInteractEvent event, Player player) {
System.out.println("PlayerInteractEvent fired");
if (event.getItem() != null && event.getItem().isSimilar(netherStar)) {
System.out.println("Item is not null and the item is the netherstar");
Main.getPlugin(Main.class).getNetherStarMenu().openInventory(player);
}
}``` so is this okay?
Static is often not needed
and then make a method like get()
But can save memory
hm
Jesus
why would i need a getter?
^
i just gave him an example its 3:17 am lol i didnt want to go thru that much
Use getters and setters because it gives you more control and flexibility of your own logic
Use dependency injection
@naive goblet why is the other one worse?
so what do i need to do now to make the gui open
no work
it just doesnt work whats the error
Well the getPlugin method is allowed and is probably in worst case scenario not that slower but the issue is that many people make a static singleton just because they need it which isn’t really why you should use one.
here are errors
i think
ah ok
so the people would start to completely centralize?
Looks like Skript
Wait wth why do you have Skript or something like that as a dependency?
idk my friend uses it
He disgusts me
amirite
it might be to do with this possibly
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
if (event.getInventory() != inv) return;
event.setCancelled(true);
final ItemStack clickedItem = event.getCurrentItem();
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
final Player p = (Player) event.getWhoClicked();
p.sendMessage("bruh bruh 69 " + event.getRawSlot());
}``` it's in the netherStarMenu class
@bronze acorn
inv?
no uh thats not it
What’s the value of that
where is skript being used in ur plugin
inv = Bukkit.createInventory(null, 54, "Skyblock Menu");
he said it's "big"
then add skript to ur plugins folder ig
Well the getPlugin method is allowed and is probably in worst case scenario not that slower but the issue is that many people make a static singleton just because they need it which isn’t really why you should use one.
@naive goblet We on about one's main class?
Yes?
:/
Palm wait, can you send your classes again?
Well.. ITO spigot, they're not real singletons.
What issue are you having, palm?
Oh Wait
Why does your eventhandler for the interact event have 2 params
You can Get the player from the event
Try removing the second parameter
Looks exceptionally suspicious
event.getPlayer()
It sends both debugs?
got a question, so bukkit inventories have to be multiples of 9 yes ? (up to 54)
Yes.
Did you even register?
So there's a stacktrace?
The exception thrown upon interacting - could you send it?
Send that error
is there a way to create an inventory with 8 or 7 slots ?
You probably get some error which consists of dots and packages
Chriskool in spigot, no
A hopper perhaps?
Nope
I mean.. Hoppers has got 5 slots.
a bit tragic they programmed it with multiples of 9
I mean you could make that work perhaps
But it wouldnt integrate nice with the end players
Makes sense
xx
Did you actually try out the new jar after changing the size?
Because it seems like spigot still thinks you’re trying to create that 6 inv slot menu
@naive goblet adding from yesterday, do bukkit runnables only work with version 1.14.4 and below?
they work in all versions
They work ^
just that Consumer<BukkitTask> is preferrable
yeah I don't know exactly which version it was added but something like that.
@wraith thicket do you know when Consumer<BukkitTask> was added into the BukkitScheduler
it
s a functional interface
I sent mail message to unban spigotMC is this email active?
I don't know
@naive goblet so u reckon it would work better if i tried it on a 1.14 test server?
But you can use this wiki and the links within it to find out :
https://www.spigotmc.org/wiki/spigot-nms-and-minecraft-versions-1-16/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Instead of asking us to spoon feed you all day please get a dev to make the plugin or watch a few java tutorials before starting with the spigot api
also, you should learn how to read stacktraces palm it's very easy to do and it will do wonders when you're trying to figure out why your plugin isn't working.
I reckon it was added in 1.13.2. @naive goblet
oh well that's earlier than I thought
Yes - it was between 1.13.1 and 1.13..2
when making a hashmap for unique inventories for this
static List<Player> playerList = new ArrayList<Player>();
for the List do i need to import java.ulil or java.awt
util
k
wait should he be using static there ?
imagine not doing this List<T> list = new ArrayList<>();
necessarily its not needed
We must love Java 7 for that diamond operator.
@frigid ember What's the collection for btw?
?
I mean, Lists.newArrayList() was for that right?
Well, Lists is a part of Guava, no?
Yes iirc
UUID :p
no
it's the same inventory
but for every user that opens it it's going to be private for them
then why have a different inventory for each player?
but for every user that opens it it's going to be private for them
Does it show user based statistic?
yeah
that makes sense then I guess
to keep track of unique players
@frigid ember I'd definitely go for an identity hashset in that case.
hm
Is that list just supposed to keep track of who has the inventory open?
List would allow duplicates
Apparently, hence my recommendation.
If so, I believe https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Inventory.html#getViewers() would work
declaration: package: org.bukkit.inventory, interface: Inventory
In your case, an identity hashset would work just fine and would be faster.
mk
Though I don't know if it's smart to keep an inventory for each player in a list or just create a new one when needed.
hashset is just a hashmap yea ?
like <uuid, inv> ?
@naive goblet I'd actually create a new instance of it when needed cause of the GC keeping clean ngl - might even be better.
yeah that's true, therefore he should go with a set most likely
shall i make a whole new class to store unique IDs
because i need to extend iterable
If he has a static GUI then there should be only one instance in total.
If he needs per player GUIs then he should have one inventory per player (keep the instance)
And re-assemble it when the gui changes
negigible
but i didnt follow the convo...
encapasulating?
idk
It's a part of OOP.
it's confusing
not really
I mean in general.. If they're immutable fields, encapsulation is.. uh..
Encapsulating is just a big word for:
Make a new class with a new variable.
The variable is private and the methods that change the variable are public,
In simple terms
just a nitpick. immutable fields = final field
There are immutable datatypes. Encapsulating those can also be important
i need to make a variable for a unique viewer using getViewers() but idk where/how to store it
why you need that?
because i need to make a unique inventory for everyone
You only need the inventory instance in most scenarios
there is some exceptions why you'd go for an inventoryview but keep in mind an inventoryview is basically 2 encapsulated inventories
there is some additional logic to it
I mean... its not absolute beginner stuff but you should know the basics about the collection framework at least
So List Set and Map are pretty important to understand
hm
List is essentially an array which you can manipulate easier. Sets are Lists that is aimed to reduce duplicate elements. And Maps is a pair based datastructure where the K acts like a Set and the elements in the Set is used to access a value which is V.
ok
And an array is an object containing other objects or primitives