#help-development
1 messages · Page 1774 of 1
the syntactic sugar from Iterable was never implemented for it
bc circular dependency bullshit
Iterator implements Iterable but Iterable requires an Iterator
but ye asIterable would be handy
doesnt need to be circulat
just allow this
for (Object o : it) {
}```
as different sugar
oh plus
i'm about to yeet my pc
my ecplise is on something
yeah but why not just allow for looping Iterator objects
true
thats entirely a source code thing
someone propose this
its actually an amazing idea
IDEs actually do a weird workaround for loop
really?
eh I prefer the while version
also sucks
I don't really use iterators so
iterators are required for avoiding CMEs
yeah but .remove
ye you can't loop and remove at the same time
You can just extend iterable and make your own adaptation for iterators i think
unless you use iterators
Adapter? Yeah.
But you'd need to do some shit like
new IteratorIterable(it) every time
or maybe Iterators.toIterable(it)
which is a bit different from it.asIterable()
(extension methods when)
Yes true..
.getName() probably
it's using .toString() by default
which, is not designed for end-users
also you're forgetting spaces lol
gg
ty
i would share the source code
but afraid someone will copy me and claim it as his
obviously its very advanced code
tutorial code?
my code
-.-
i actually did change something from the tutorial code lol
player.sendMessage(ChatColor.AQUA + "Welcome " + player.getName() + " To The Server !");
the tutorial only says " welcome to the server"
Bukkit.broadcastMessage("test");
}
``` i feel stupid asking but does anyone know why this isnt broadcasting the message?
seems fine to me
fixed everything
all my problems was just my eclipse on crack
😄
I'm curious as to why everyone prefers string concating for colours instead of using ChatColor.translateAlternateColorCodes
It’s generally the way you should do it
I wonder if the compiler optimizes the later, probably not
Ahhh interesting
Readability
I don't know what the heck &3 is
Its possible to use these ?
I have been scammed
It’s technically possibly to use anything else than & but apparently & has become an unspoken convention
Wonder what happens if you try and use a color char
Lmao that sounds so cursed
Nah use bb ;)
lemme use my minecraft bb gun xD
are you kidding? 
b is banana color
well lemme ask what is the more readable way to do it?
thanks
how can i edit the velocity entity after hit? (I mean this entity recoil when I hit it). Do I have to cancel the event and give myself the damage and velocity, or is it some other option?
You could apply your own velocity 1 tick later
I'm trying to use holographic displays api for my plugin but maven is saying that the dependency is not found
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>```
Dependency 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0' not found
anybody know how'd you fix this?
yea, an error pops out Could not find artifact com.gmail.filoghost.holographicdisplays:holographicdisplays-api:pom:2.4.9 in spigotmc-repo
It won't be in the spigot repo
Does a .gitignore still work if you add it late
I have my project in a repo and now I want to add a .gitignore will I need to delete every file in the repo for it to take effect?
Yes it does work even if you add it post-initial commit and push
Commit it
yea, I still see the files though
You might have to delete those files in the remote repo manually
Since git ignoring won’t inherently do it
anyone know how to check if someone ops themselves?
and how to de-op someone?
ok but does anyone actally know how to use ChatColor.getByChar
because that shits confusing asf
so basically my friend has been cheating on our server and we wanted it to stop... I am coding a plugin to check if he is oped and if so de-op him... and I also want to know if he ops himself again and how I can stop that
acc im fine now nvm
Just take his console access lmao
What are you using to host
what does that mean?
Because realistically the only way he can get op again is if he gets it through console or someone gives it to him
Who owns the server
oh is that the one where u go on the server
and you can click the server to ur own server
or smth like that
something like that
Well how is he getting op
basically we all share an email address(I know it sounds bad)
there is a console on the website's server
when you start the server
There's nothing you can do if you share an email lmfao
meh I thought it would be a bad idea but we went with it anyway XD
so back on topic?
I don't think there is an op event
hmm
You would have to take a different approach
My best idea would be to choose an event and then within that event, check if he is oped then if he is just deop him
uhm just check if the command sent has /pardon or /unban in it
how can I check that? @tranquil viper
PlayerCommandPreprocessEvent
That's only if a player unbans him though
not console
Anyone know what the clicking sound in crate plugins is? Been trying to find it for like a day now
Can you send an example?
I think it’s one of the noteblock instruments
Note block pling
how i can create a custom world generator that extends vanilla generator?
e.g: only to place custom houses or trees
BlockPopulator
can you show me examples?
What is the proper way of reloading one plugin for quick development changes
I know I use /reload but that causes problems every once in a while
I’ve never had issues personally
Maybe if you are developing a plugin that has dependencies that don’t behave
Randomly my server just won't reload lmao
it gets stuck reloading and I have to stop and restart my server
jstack and find where it's stuck
Probably in the middle with you
hey ima new dev
and im trying to start spigot plugins i got a problem
when i click new it wont show java class
make sure it's inside src/main/java
it said my new package
oh wait
i read that wrong
it is inside
you need to create a package first ideally
i did?
do blocks lose their meta data like lore info when placed and broken in the world ?
well idk, when you try to create a new file when right clicking the java folder
can you create a java class?
Yes but I think you can prevent it with a database
you can create the java class directly
so click the create new java class
and put io.github.creeperz653.bedwars1085-geysersupport.YourClass
Your class name
Yes
- is not valid in a package name
theres nothing in the package
im making it then ima learn java along the way
dw about it
its basicly a test
ioh
Delete -
What?
can you put spaces
No?
And now create java class named your plugin inside package
😐
more then one file showed
I told you to remove it - in the package
i did
you didn’t remove it?
Is it possible to manipulate the outcomes of an enchanted item from an Enchanting Table?
I currently have this at the moment although I might not be correct with switching the ItemStacks.
@EventHandler
public void GiveItem(EnchantItemEvent e) {
if (e.getEnchantBlock().getType() == Material.ENCHANTING_TABLE) {
this.plugin.getLogger().warning("Attempting to change item to chicken.");
ItemStack oldItem = e.getItem();
ItemStack newItem = new ItemStack(Material.CHICKEN);
newItem.addUnsafeEnchantment(Enchantment.MENDING, 255);
oldItem = newItem;
}
}
you can set the result of the event
maybe
I don’t remember, maybe it’s in CraftItemEvent
Hmmm what do you mean by "set the result of the event"?
event.setResult(ItemStack)
Or something like that
Maybe this method exists in PrepareEnchantItemEvent
- is now in their folder name so yea that's fine.
🤷♂️ Then idr
And with PrepareEnchantItemEvent, it's better to obtain and modify the offer listing instead of actually returning the final "ItemStack"
All goods haha
, class inside package without plugin name
Just domen.ClassName
domen.pluginname.ClassName
It's standart🥺
Yea that's true 🙂
What's the reason you are adding bedwars support for Geyser ? The only thing that's not functioning is void death, if you die on java you get respawned on touching void while bedrock just hits it as "floor"
Ahhh i figured it out. Had to edit the ItemStack directly from the event rather than replacing it with a new ItemStack
hey so i managed to do everything smoothly but i got a problem
uh
i dont see the maven tab
Terminal -> mvn clean install
???
yeah i see the tab what do i click for it to conpile
package
i did click it already
i dont know where my file folder is
sadly
🤦♂️
Well if you're lucky enough, the run window would've told you where it is
Alternatively you can right click the target file inside your IDE -> Open In -> Explorer
yeah marven didnt run it
i dont see a target file
Was there an issue compiling?
I wonder what he is trying to compile
it feels like absolutely everything is wrong there
😋
im using spigots guide bruh
i dont think i clicked the right thing
Just interesting
Did this little window pop out?
Lifecycle
Package sits under the lifecycle tab
Can you send me the entire logging of the compiler?
k
[INFO] Scanning for projects...
[INFO]
[INFO] ----------< io.github.Creeperz653:BedWars1085-GeyserSupport >-----------
[INFO] Building BedWars1085-GeyserSupport 1.17.1-R0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BedWars1085-GeyserSupport ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ BedWars1085-GeyserSupport ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\7\IdeaProjects\BedWars1085-GeyserSupport\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.461 s
[INFO] Finished at: 2021-11-17T22:26:44-08:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
What's in your classes file in #help-development message ?
sadly not a jar
Hrmmm, im not too sure then. I didn't have any hiccups following that guide.
i mean
im at the plugin.yml part
then i pressed conplie
oh
i didnt press package
i pressed conplie
POGGERS
i made my frist java JAR
LETS GO
Good job
Uhhh im learning as well, only picked up SpigotAPI since last week.
Made some plugins that used the XP system as a health bar, some that communicate to a MongoDB server, some that handles other plugin's API like citizens and currently making a tweak to obtain higher vanilla enchantment levels and cool drop box system with a gui interface
oh nice
tbh
ive wanted to make plugins
for a lONG time
just was too lazy
What are you trying to create 🙂
forgot
jk
Im making a addon
to a big plugin
that adds geyser support legit in the name ive posted
bedwars1058 im making a addon for it
Yea I'm aware :p I've also made a few plugins for geyser 🙂
what
I KNOW YOU
YOUR JENS
YOU MADE
GEYSER HUB
( i think)
Yup 🙂
Caps Lock stuck?
whats the offical discord
I saw that 😳
?????
Sus
Yea sure 🙂
dm offical geyserhub discord server
Done 🙂
aqua!
go format color wiki when... when i was still using 1.12 i always have it there on my important bar lol https://minecraft.gamepedia.com/Formatting_codes
A book showing the possible formatting options with the character that performs them.
Formatting codes (also known as color codes) add color and modifications to text in-game.
Text in Minecraft can be formatted with the section sign (§). In Bedrock Edition, the section sign can be entered into signs, world names, books, renaming items and ...
could be a stupid question but
to change this' name
how
or should i just do it trough file explorer ?
shift + f6
thank you very much that you didnt hack my computer
does this work to change the plugin's name also ?
lol
Yuh shift f6, or well it’s called a refactor which you can find by right clicking the class
Yeah
refactor in intellij is very good
IntelliJ is good, because it understands that changing the name of a class is a semantic change to the system
Not just a simple name change
you can refactor method, class, etc
oh thanks
damn that's op
progress :D
added :
-/heal or /heal player
-/feed or /feed player
-join message
-welcome message
F2 works also
Maybe have a . at the end of the sentence
oh yeah ok
No need to specify that it's a player imo
lol
Healed shakiz.
I personally don't really like using text that isn't that big in that box chat, I would prefer to use that text in subtitle (player.sendTitle("", "Nice text here", 10, 40, 10)) or might be actionbar (p.sendActionBar("") and only if you use paper, else then you should make yourself a method using the nms then)
how do i fix this ```java: error reading /C:/Users/Shakiz/Desktop/myplugins/BwCore/src/online/shakiz/BwCore/Commands/gm.java; C:\Users\Shakiz\Desktop\myplugins\BwCore\src\online\shakiz\BwCore\Commands\gm.java (The system cannot find the file specified)
i changed the file name using refactor
nvm i just changed it back
and rechanged it and it fixed
Hello everyone, I have a little problem. I tried to create a command that teleports players to a location specified in the config.yml, but somehow it keeps teleporting me to 0, 0, 0.
I am not close to my pc rn, but I recreated the part of the code which I think has the error.
for (Player player : Bukkit.getOnlinePlayers() {
double spawnX = config.getDouble(„locations.player.spawnX“);
double spawnY = config.getDouble(„locations.player.spawnY“);
double spawnZ = config.getDouble(„locations.player.spawnZ);
World world = player.getWorld();
Location loc = new Location(world, spawnX, spawnY, spawnZ);
player.teleport(loc);
Bukkit.broadcastMessage(„§eDu wurdest zu deiner Startposition teleportiert“);
}
In the config file, I set spawnX to -120.85732959, spawnY to 69.0 and spawnZ to 361.937492572
i have a problem
[01:27:02 ERROR]: Could not load 'plugins/BedWars1085-GeyserSupport-1.17.1-R0.1-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `io.github.creeperz653.bedwars1085geysersupport'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:75) ~[patched_1.17.1.jar:git-Purpur-1427]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Purpur-1427]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Purpur-1427]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Purpur-1427]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[patched_1.17.1.jar:git-Purpur-1427]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:322) ~[patched_1.17.1.jar:git-Purpur-1427]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1231) ~[patched_1.17.1.jar:git-Purpur-1427]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[patched_1.17.1.jar:git-Purpur-1427]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
Caused by: java.lang.ClassNotFoundException: io.github.creeperz653.bedwars1085geysersupport
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:153) ~[patched_1.17.1.jar:git-Purpur-1427]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:105) ~[patched_1.17.1.jar:git-Purpur-1427]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:466) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:73) ~[patched_1.17.1.jar:git-Purpur-1427]
... 8 more
im trying to load it
plugin.yml?
your class path should be io.github.creeperz653.bedwars1085geysersupport.bedwarsgeysersupport
main: io.github.creeperz653.bedwars1085geysersupport.bedwarsgeysersupport
``` ^ in `plugin.yml`
also make the class name camel case (MyClass) please
in your case BedwarsGeyserSupport
much easier to read
?
done
changed
your class is in io/github/creeperz653/bedwars1085geysersupport right?
ok
do you know why you have to enter that
instead of what you had before
no bc my brain is smooth
learn basics
now it should work
but i would first of all make your class name BedwarsGeyserSupport
instead of all lower case
and then you would have to change
main: io.github.creeperz653.bedwars1085geysersupport.bedwarsgeysersupport
``` to
```yml
main: io.github.creeperz653.bedwars1085geysersupport.BedwarsGeyserSupport
io.github.creeperz653.bedwars1085geysersupport is the package your class is in (the folder) and the .BedwarsGeyserSupport is the class name
mhm ik
ok
bedwars1085?
epic spelling
nice
uwu
sus
SUS
hey question
when someone issues a command like this
/test player uwu
to get the 2nd or 3rd argument we do args[2] or args[3] ?
with this declared before
or am i stupid
yep
ayyy
but args[1] for 2nd
hey btw
@Override public void onEnable() { //Disable if pl not found if (Bukkit.getPluginManager().getPlugin("BedWars1058") == null) { getLogger().severe("BedWars1058 was not found. Disabling..."); Bukkit.getPluginManager().disablePlugin(this); return; } }
would i make another file for this?
you mean class?
mhm
do i put it in main
yeah
you always put onEnable, onLoad and onDisable in your main class
otherwise they dont even work
package io.github.creeperz653.bedwars1085geysersupport;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class bedwarsgeysersupport extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
@Override
public void onEnable() {
//Disable if pl not found
if (Bukkit.getPluginManager().getPlugin("BedWars1058") == null) {
getLogger().severe("BedWars1058 was not found. Disabling...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
}
}
}
what
put onEnable outside of onDisable
package io.github.creeperz653.bedwars1085geysersupport;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class bedwarsgeysersupport extends JavaPlugin {
@Override
public void onEnable() {
//Disable if pl not found
if (Bukkit.getPluginManager().getPlugin("BedWars1058") == null) {
getLogger().severe("BedWars1058 was not found. Disabling...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
}
wtf
they are methods
they belong in classes
not other methods
this
thats what i put
nvm
Hey, is it normal that Bukkit.getOfflinePlayer(uuid)#getName() returns null even if the player did join the server before?
Seems like i can do getName() and have players name, but if they didn't join for like a day it returns null
i think its stored in usercache.json
if theres something clearing it then thats the problem
That's odd
Considering it queries the mojang api
Are you sure you're running an online server?
yes
😮 no w a y
I think if you get an offlineplayer via UUID it doesn't necessarily fetch the name
could be wrong
you might have to store the name with it, or manually query the mojang api
I think i will need to store the player name in my config
rly strange behaviour though...
(Java)
This method uses the mojang API to convert from a UUID to the player's username.String getName(UUID UUID) {
try { URL url = new URL("https://api.mojang.com/user/profiles/" + UUID.toString().replace("-", "") + "/names"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Accept", "application/json"); connection.setDoOutput(true); connection.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } reader.close(); return builder.toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
there we go
definitely should cache it
thx will try
else if (p.getLocation().getY() >= ConfigManager.cfg.getInt("gamehigh") - 1) {
p.getInventory().clear();
ItemStack Stick = new ItemStack(Material.STICK);
ItemMeta StickMeta = Stick.getItemMeta();
StickMeta.addEnchant(Enchantment.KNOCKBACK, 1, true);
Stick.setItemMeta(StickMeta);
ItemStack Blöcke = new ItemStack(Material.SANDSTONE, 64);
p.getInventory().setItem(0, Stick);
p.getInventory().setItem(1, Blöcke);
}
how can i do this only once and not all the time when the player is under this height?
hey
i need help
so i can understand pretty much almost any java plugins tutorials
but
this one
Code in the video can be found on my github which is github.com/Scifi9902/
Social Medias:
Twitter: twitter.com/Scifi9902
Telegram: @Scifi9902
Discord: Scifi#1321
MC-Market: https://www.mc-market.org/members/63425/
Github: https://www.github.com/Scifi9902/
what even is this lol
i dont understand almost anything he did here
in the start phase
pls
He made a type aware manager thing
It’s generics if you’re curious
The type parameters and that stuff
hm
i dont understand
what should i know to understand this ?
like any videos ?
also thank you
if i create this new file and use the file, will it use the new created file ?
No
when you use new File(... its creating a pointer to where a file MAY be
it could be a folder, or it may not exist
when you call File#createNewFile() it will attempt to create a file at that location, IF one does not already exist.
teh return of the method tells you what happened
I guess you didn;t read what I typed
I already told you no, and why
so wtf should i do
is this ok ?
are you actually trying to replace a file, or just create one if its not already there?
create a new file
that doesnt
and CANT
cause i will have a list of arenas
and if the name is in it
it will give an error
that an arena with this name exists
!
so what should i do now @eternal oxide
File file = new File(Trex...
try {
file.mkdirs();
// Create file or save resource here
TrexFFACore.INSTANCE.saveResource("fileThatsInYourJar", false);```
bruh the file is not in jar
i know how to create custom configs
but files for data
for each arena
or player
create the file
load it
and set stuff
then you create an empty file in memory, add what you want and save it
how to
FileConfiguration data = new YamlConfiguration.load(); or something close
bruh dude
i want to create a file in java
and use it
can you help me do THAT ?
and maybe load it with yamlconfiguration
you don;t use an empty File, its pointless
you create a File when you have somethign to save
im going to set the name
and save it
is it hard for you to help me with the thing that im going to do
?
I have told you everything you need to know, but you listen as well as my wife does.
Hi all,
I was wondering, what is the easiest way to create a blank text document in a specified path (e.g. the folder that a Plugin creates).
In the...
you have a wife? 🤔
I know its surprising, but someone was willing to marry me 🙂
You just have to lock them in for a while and their will breaks down.
you are not helping AT ALL
ok
im not going to save a yml file to my plugin folder
for every arena name possible
and save the resource
i want to know how to create a file
in java
and load it
is it that hard for you to help me with that ?
As I already said, you don;t create an empty file. You create yoru data in memory, THEN save it to file.
old and irrelevant
and i asked you how to create a file in memory
and save it
and you gave the load config method
someone please help, my intellij intellisense is bugged
and I already told you, data = new FileConfiguration("path").load() or somethign close
i litearlly created Inventory inv up there
and how to save it
data.save();
its not bugged, there is no method createInventory() which takes no parameters
You are not inside the method
you mean YamlConfiguration.load() ?
what to put in params
the path
wdym
Bukkit.createInventory...
the same as if you were trying to load a yaml
wher
i declared it
but
i have worse problems with itemstacks
You need to put it in a method...
you are writing it outside the method, which is in field area
and as others told you, code goes inside methods
i could do it before...
Doubt
wdym
You can't do what you are doing in field area
um
you are trying to write code at teh class level.
is that a problem?
i did it before
it worked
You can define and initialize variables/Fields but it has to be in teh same line as you define it.
else it has to be initialized inside a method
what do you mean by "not work"?
.
and when i uninstall and reinstall it works again
but i cant keep doing that
it looks like you are in a method which already has a variable called item
that's the thing
im not
package net.fordium.skyblockremake.CraftingTable;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class CraftingInventory {
private Inventory inv;
public void createCraftingInventory(Player p) {
inv = Bukkit.createInventory(p, 54, "Craft Item");
for (int i = 0; i <= 53; i++) {
if (!getCraftingSlots().contains(i)) {
if (i == 24) {
inv.setItem(24, new ItemStack(Material.BARRIER));
}
}
}
}
ItemStack item = new ItemStack(Material.STICK);
item
public List<Integer> getCraftingSlots() {
List<Integer> craftingSlots = new ArrayList<>();
craftingSlots.add(10);
craftingSlots.add(11);
craftingSlots.add(12);
craftingSlots.add(19);
craftingSlots.add(20);
craftingSlots.add(21);
craftingSlots.add(28);
craftingSlots.add(29);
craftingSlots.add(30);
return craftingSlots;
}
}
this is the entire code
You only typed item, there was no period
add a period, then look at teh code complete
lemme send
THERE IS NO CODE COMPLETE
when i add period
can i stream?
somewhere
and again you typed item at teh class level, you are outside any method
but i have created tons of items like this
and they worked
but then after using the ide for some time
@eternal oxide right ?
the code complete dies
not outside a method you didn;t, not without a code block
pwdym
do you know what a method is?
to use item like you are trying, it has to be INSIDE a method or a codeblock
okay
nested method
you are writing it outside the method/codeblock that's why there is no auto-completion/suggestion that you wanted
ill just uninstall and reinstall real quick
it works that way
somehow
teh IDE is expecting only Field definitions at that level
it has no idea what you are trying to do so its completely confused
declarations and instantiating is run when the class is created
the code isn’t necessarily linear, you could make a static block and it’d run linearly
but ultimately your scope is incorrect
how so
i tried to do exactly what the if statement says
but it doesnt work
i was just testing and idk how to fix this error
the full error probably mentions null
most likely you want the item modification to be done in the constructor
yes
See which line it says has the null
When you have found the line it says is null, look at your code and see if you can understand why
i dont understand where it says null
how can i read it
at online.shakiz.BwCore.Commands.enchant.onCommand(enchant.java:22)
what's the theme
i mean understand the error
you look for teh Caused by line
ohh
ok i'll try to see if i can fix
which theme?
one dark theme
what
okay
why delete :(
Incorrect information
I’d recommend using pastebin or a text website for code / errors
images are meh
and don’t upload it as a file either
ì dont have nitro ;-;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.annotation.Target;
public class enchant implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(" §dThis command can only be run by players");
}
else if(args.length==3){
Player target = Bukkit.getPlayerExact(args[1]);
ItemStack hand = target.getInventory().getItemInHand();
Enchantment enchantment = Enchantment.getByName(args[0]);
int Level = Integer.getInteger(args[1]);
hand.addUnsafeEnchantment(enchantment,Level);
return true;
}
else{
sender.sendMessage(" failed!");
return true ;
}
return true;
}
}
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
icodex
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.annotation.Target;
public class enchant implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(" §dThis command can only be run by players");
}
else if(args.length==3){
Player target = Bukkit.getPlayerExact(args[1]);
ItemStack hand = target.getInventory().getItemInHand();
Enchantment enchantment = Enchantment.getByName(args[0]);
int Level = Integer.getInteger(args[1]);
hand.addUnsafeEnchantment(enchantment,Level);
return true;
}
else{
sender.sendMessage(" failed!");
return true ;
}
return true;
}
}
What’s wrong with the above code?
this
args is indexed on 0 not 1
player and level are getting from the same index, not possible
i do this
Why do you use getPlayerExact
you are tryign to get a player from args 1
args 0 is sharpness, 1 is 100, 2 is shakiz
it should be target = Bukkit.getPlayerExact(args[2]);
yes
u put 1 in the args[1]
xD
im stupid
why not use Bukkit.getPlayer
and if it didnt find the player
just send a message
The player is either offline or doesn't exist
EZ
ok i'll try
will Objects.requireNonNull change the functionality? or im doing it just for the sake of the ide shouting at me to do it
i used getplayerexact cuz its the only one i know of xD
xD
Player player = Bukkit.getPlayer(args[2]);
if (player != null) {```
still issue
how can i recreate the crafting table from hypixel skyblock?
create new inventory and put the blocks in their right position?
yeah but how do i check for the crafting recipes
hmmm idk i dont really know about all of these GUI
and more importantly
how do i set the product item
https://paste.gg/p/anonymous/3dba6ba951184aaf907404d2a57b8a5a I've never edited a meven file before 😆 but i can't seam to add NuVotifier to it. it just goes red where I add it as a dependancy
The paste file is my pom.xml file
did you reload maven repo?!?!?!
no, how would i do that (in intellJ)?
oh i see what you are talking about now
what’s the error?
wait 1 sec i think it worked
this was the error
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.lang.annotation.Target;
public class enchant implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(" §dThis command can only be run by players");
}
else if(args.length==3){
Player target = Bukkit.getPlayerExact(args[2]);
ItemStack hand = target.getInventory().getItemInHand();
try {
Enchantment enchantment = Enchantment.getByName(args[0]);
int Level = Integer.parseInt(args[1]);
hand.addUnsafeEnchantment(enchantment, Level);
}
catch (IllegalArgumentException e){
sender.sendMessage("§cInvalid Argument !");
}
return true;
}
else{
sender.sendMessage(" failed!");
return true ;
}
return true;
}
}
and this is my code
now it gives me this as error
what
i have put 3
Java always starts at 0
That’s different from my screen
oh
anyways
this is my code rn
add e.printStackTrace(); to your catch
im assuming though the enchantment name is wrong
could be capital sensitive
[16:05:00 WARN]: at org.apache.commons.lang.Validate.notNull(Validate.java:192)
[16:05:00 WARN]: at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack.addUnsafeEnchantment(CraftItemStack.java:184)
[16:05:00 WARN]: at online.shakiz.BwCore.Commands.enchant.onCommand(enchant.java:27)
[16:05:00 WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[16:05:00 WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:146)
[16:05:00 WARN]: at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1189)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1001)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[16:05:00 WARN]: at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[16:05:00 WARN]: at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713)
[16:05:00 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616)
[16:05:00 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)```
ok i will try
lshould i add the minecraft:sharpness thing ?
nope that didnt fix
yeah invalid enchantment
oh
weird
idk how to fix ;-;
pog
i looked here and copy pasted this
then it worked
i'll try to find a way to make it ignore caps
nah
.toUpperCase()
oh
use .toUpperCase()
# HELP player_count
# TYPE player_count gauge
player_count 1
# HELP cpu
# TYPE cpu gauge
cpu 2.652843
# HELP uptime
# TYPE uptime gauge
uptime 2973630
# HELP threads
# TYPE threads gauge
threads 184.000000
# HELP gc
# TYPE gc summary
gc{name="G1 Old Generation"} 0
gc{name="G1 Young Generation"} 5366
# HELP tps
# TYPE tps gauge
tps 20.000000
# HELP mspt
# TYPE mspt gauge
mspt 10.858425
# HELP loaded_chunks
# TYPE loaded_chunks gauge
loaded_chunks 9197
# HELP entity_count
# TYPE entity_count gauge
entity_count 786
# HELP packets_rx
# TYPE packets_rx gauge
packets_rx 71415
# HELP packets_tx
# TYPE packets_tx gauge
packets_tx 8575903
# HELP disk_space_world
# TYPE disk_space_world counter
disk_space_world{world="world"} 1681992267
disk_space_world{world="world_the_end"} 90885096
disk_space_world{world="world_the_nether"} 187266488
# HELP loaded_chunks_world
# TYPE loaded_chunks_world counter
loaded_chunks_world{world="world"} 8356
loaded_chunks_world{world="world_the_end"} 0
loaded_chunks_world{world="world_the_nether"} 841
# HELP entity_count_world
# TYPE entity_count_world counter
entity_count_world{world="world"} 756
entity_count_world{world="world_the_end"} 0
entity_count_world{world="world_the_nether"} 30
# HELP free_memory
# TYPE free_memory gauge
free_memory 2653133552
# HELP total_memory
# TYPE total_memory gauge
total_memory 5368709120
# HELP max_memory
# TYPE max_memory gauge
max_memory 5368709120
?paste @analog prairie
hmmm i wonder why do bukkit team use wrapper for the potioneffecttype and enchantments hmm?
What format is this file
but there's other enchants like arrow_knockback ==> punch
Can anyone help me?
What format is this file?
Isn't json or yml
How can I read it
idfk
you'd have to find a spec
but if you don't even know the format, then good luck
the fuck is the file extension btw
uhh well
you could do something like
String name = args[0];
switch (name.toUpperCase()) {
case "PUNCH": return Enchantment.ARROW_KNOCKBACK;
// insert other specialized cases here
default: return Enchantment.getByName(name);
}
to explain what a switch statement is, if you don't already know:
?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.
best way to explain lol
So switch is a conditional just like if, but the main difference between the two is that switch has to evaluate the value of a non-object (except for Enum/String) type.
or else you will hear maow talking about it for 1 hour straight if you cant understand him
This is because switch can do branches faster than if.
if has to evaluate every single else if which reduces speed the more branches you have (and is just generally ugly to look at)
switch doesn't because it just jumps to the correct branch.
To give an example:
if ->
else if ->
else if ->
else if ->
else if ->
else if ->
else if ->
we stop here > else
For each else if, it has to run that condition, so to get to the else it has to go through everything else.
In a switch:
case
case
case
case
case
case
we stop here > default
You can notice it doesn't have to go through any of the cases.
So ye, use switches when you can.
Word of warning for switches tho
For each case, you should either end it with a break or return
This is because if a case is matched and there's cases below it, the switch will continue into the cases below that case.
This is called switch fall-through and is shit, for the most part.
Also in a newer version (Java 13+) this can be changed to:
var name = args[0];
return switch (name.toUpperCase()) {
case "PUNCH" -> Enchantment.ARROW_KNOCKBACK;
default -> Enchantment.getByName(name);
}
This is called a switch expression ^
i understand
when return and when break ?
return for if you need to end the method/return a value, break if you don't
when it finds a place to return at
oh ok
How do I set it so when a bed is placed next to another bed and both players sleep on it, a command is execute
you dont have to use switch there
you can just do some string manipulation
That wouldn't work as it converts an enchantment to a user-friendly name, as opposed to what you need to do, which is the exact opposite.
should i change it to be return swtich(name.toUpperCase()){?
oh
am confused
but i'll try to understand now
and make it work
i get that i'll need to use switch return
ARROW_DAMAGE results in Power, as opposed to power resulting in ARROW_DAMAGE
So... just use the example I sent far above.
.
i'll fix that
and use it
i mean i'll use it to make it work
case* =original
return = what its transfered to
right ?
or am i stupid
p'much
wdym ? o.O
I honestly have no idea
holy shit he's actually making it
But ye Pulse please explain to the beginner how to convert ARROW_DAMAGE to Punch or vice versa without a switch? /s
case "PUNCH" -> Enchantment.ARROW_KNOCKBACK;
is this a good way to type it ?
or does this translate to :
return:"ARROW_KNOCKBACK";```
depends on which version of Java you're usin'
17 👀
ye use the top one then
ok thank you
u trynna make sex ? XD
Yes
LMAO
It spawns a baby villager
lol
Dont wanna say it openly
imagine asking "how to make a sex plugin"
cant wait to see the servers that use ur plugin lol
oh idk
hmm
i am noob
but
maybe if you get the location of the beds
and then get their x loc or y loc of the beds
and then see if one is equals to first one + 1 or -1
then they are technically next to each other ?
but idk
@naive rose
Good odea
but it'l depend on the bed rotation
Hey, is there a shield use event?
Yep
👋 hii - is there any way to make breakNaturally() drop the contents of things like furnaces, droppers etc? i've specified that it's broken with a pickaxe but that doesn't change anything
has everyone a idea why i become this error
ERROR:
CODE:
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<type>bundle</type>
</dependency>
i use vscode with maven !
Which is built-in
Isn't Gson starting to be out dated too
why so
Well yeah, I mean like it seems to be on that path
For example? Moshi?
Yeah Moshi
why would someone ask for a plugin variable in a constructor in a command class if every class does it with the same instance and it keeps the same?
call super(plugin)
Yuh
also cant you make a constructor in your class extending JavaPlugin?
The biggest upgrade is probably moshi’s type adapter system
And its minimalistic api
You can
But it has to be a nullary one
And iirc public also
Though that’d basically just be a normal init block
int x = random.nextInt(999999999);
int y = 100;
int z = random.nextInt(999999999);
oki great
How can i do to make that the nextInt have to be at least x blocks of distance?
- x blocks of distance
Wait wym?
that works?
You probably want to roll another int with the range x to something bigger than x
new Random().nextInt(10) + 5; // will return something form 5 to 14
I think they just want a minimum value
i guess
random.nextInt(max - min) + min;
but
That will give you a random number within min and max