#help-development
1 messages · Page 2141 of 1
Wait no I'm dum again, I read your message wrong. My bad
think they removed the table
for each packet
i cant find it on the site
Use org.bukkit.block.Block maybe?
yes
@EventHandler
public void onInteract(PlayerInteractEvent event){
Player player = event.getPlayer();
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
Block block = event.getClickedBlock();
if(block.getType() == Material.DIAMOND){
player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
}
}
}
Why does it nothing when I click on a diamond block?
lol 🙂
Np :>
Can I also make an event when you click on a diamond block nothing happens until you have a shear in your hand called "name" or so?
Ofc?
How can I do that?
all imports is good
Item.getItemMeta().getDisplayName().equals("Whatever");
Though, you might need to do "Whatever".equals(ChatColor.stripColor(Item.getItemMeta().getDisplayName()))". Idk if chat colors are important in .equals
public void showGlow(Player player, Entity target) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, target.getEntityId());
WrappedDataWatcher watcher = new WrappedDataWatcher(player);
watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x40); //glow
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
@echo basalt
i got this much
It's fine 🙂
errors out
hm oke
👍
Item.getItemMeta().getDisplayName().equals("Orange");
Why does it says cannot resolve "getItemMeta"
Item is a class
Is Item an ItemStack instance
huh
Name it to “item” and try
I imported Item
No Item is an entity class
You need to do player.getInventory().getItem(slot).getItemMeta() if you haven't
.getItemMeta() is from the ItemStack class, not Item interface
ye
Item is an itemstack being dropped
It is the entity representation of it ye ^
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
Block block = event.getClickedBlock();
if(block.getType() == Material.DIAMOND_BLOCK){
player.getInventory().getItemInHand().getItemMeta();
Item.getItemMeta().getDisplayName().equals("Orange");
player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
Still "getItemMeta" cannot resolved
player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange")
ohw
This player.getInventory().getItemInHand().getItemMeta(); just gets the item meta, and does nothing with it
Ohh oke
item in main hand might be null so null check that
^
what?
Also, do getItemInMainHand() instead
if player.getInventory().getItemInHand() is null
so also make an else?
getItemMeta() can be null, check using hasItemMeta()
i had slots where the itemstack was null
i am new to java so i dont know what you mean, sorry :/
thats only for Inventory contents
Not all ItemStacks have ItemMeta
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock().getType() != Material.DIAMOND_BLOCK
|| event.getItem() == null || !event.getItem().getItemMeta().getDisplayName().equals("Orange"))
return;```
calling getItemMeta() can return null
um
literally "null" in chat or what?
This @quaint mantle
a null in java means no object. Your code will thrown a NullPointerException
Can you explain to me what it means so I can learn more?
ohhwww yea nothing is happening now with my code :p
so does that means it is null?
Not necessarily, if item is null and you do item.getItemMeta() for example, Java will print an error as you try to get the meta from an item that does not exist. So who's meta should it return if the item is null? Java does not know, and crashes
null safe languages 💟
i found an error preventing shutdown and none of the stacktrace leads to my plugin
is that a bug
it has smth to do with aquifier gen
player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");
player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
So I got this now, but every block called Orange get the message. How can I make an else statement here?
That is kind of a pain tho imo, since your code works but does not do what you want it to...
What do you mean?
Write what you want with words :>
Can I like do when a shear called "Orange" can only activate the message?
The frick Index 117440804 out of bounds for length 315
no stack trace to spigot either
¯_(ツ)_/¯
not my code
You need to test the material of the held item, and the display name of the item
item.getType() and item.getItemMeta().getDisplayName()
and how do I check if the item is a shear?
item.getType() == Material.SHEARS
tyy
Np
item.getType() == Material.SHEARS
player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");
so I could do this?
nvm
I cant
player.getInventory().getItemInHand().getType() == Material.SHEARS && player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");
Tysm 🙂
🙂
Though, it might be smart to store player.getInventory().getItemInHand() as a variable
ItemStack item = player.getInventory().getItemInHand();
how do i do that?
So fast
so every time when I use item it means player.getInventory().getItemInHand();?
Yes
ah okay
btw here, why do you use && on the end of the first line?
&& = and, || = or
okay
so you can see || as an else?
Yes
@EventHandler
public void onInteract(PlayerInteractEvent event){
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInHand();
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
Block block = event.getClickedBlock();
if(block.getType() == Material.DIAMOND_BLOCK) {
item.getType() == Material.SHEARS &&
item.getItemMeta().getDisplayName().equals("Orange");
player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
}
}
}
So this is a good code?
Hey there, I have been scrolling through alot of documents and forums to find more information about redstone dust.
My setup
I want to itterate a redstone signal from source to end. Where sometimes you power a block and sometimes the redstone powers something else or makes a turn.
My problem
What I am trying to find out is how to read the redstone dust shape. In debug mode (F3) you can somewhat see sides and directions. Altough I have no clue on how to get these values. block$getFace will only return to SELF.
tl;dr: I was wondering if there was a way to check the shape OR facing/direction of redstone dust. 1.8;)
?jd-s
managed to make the main thread kill itself
lol
damn, log4j?
yep i managed to get stack trace into log4j
all i did was force load a few chunks...
I was more talking about the security vulnerabilities
how can you see if you still have that security vulnerability?
I just straight dont use log4j since i heard of that vulnerability
It is probably the watchdog
Still points "Self"
as facing
Cannot
i didnt either
Did you even use my method?
its part of the server
Didnt see any of what you send
no
Uhh, not really. You have forgotten a few parenthesis etc. I would have done something like this
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock().getType() != Material.DIAMOND_BLOCK
|| item.getType() != Material.SHEARS || !item.getItemMeta().getDisplayName().equals("Orange"))
return;
player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
}``` What this does is that it test the following: `If you didn't click a block OR the clicked block isn't a diamond block OR the item in your hand isn't shears OR if the shears' display name isn't Orange`, then return. Aka, if something is wrong, return and do nothing. However, if all is good, send the player a message.
i can offer you infinite power
What version are you using
💀
Yeah...
Well there's your issue dude
Stop using a version that's 8 years old
^
Why are you even on 1.8?
for the pvp props
Some pvp servers are good for 1.8
On 1.8 I believe redstone wire connections are computed, not stored
I didnt complain
nah
lol
Honestly we should just not allow people to ask for help for 1.8
it was a response
It is 8 years old and no longer supported
ah yes, stackoverflow also limits to 1.8+
would be nice to see this place change to it
Upgrade
Right because it's frustrating trying to help people using extremely outdated versions
Idk, please tell me. I need it
is it?
Kinda yeah
Yes, very
you should take a break from your screen, doesnt sound good worying about it 😉
What a condescending reply
"I don't want to help people who are using a version that has been unsupported for years"
"Go touch grass"
💀
No you're not lol
you know what? even im gonna touch some grass rn, you both should too. chill out.
no need to get all stackoverflow on me
same, goodjob
how would i reset a chunk to the original terrain?
Don't think there's a good way to do that anymore
rip
you would probably have to keep a backup of the original terrain for each loaded chunk
bruh
If there was a ChunkGenerator for the default vanilla generator it would work
But alas there is not
Why tho
I dunno, the generator for the default terrain is just null
Isn't that, like, very useful
Maybe open a feature request on the jira?
no
ok
they obfuscate stuff anyways, no reason to lol
Does any one have a good obfuscator allowed in spigot plugins? Idk what classifies as "not too good obfuscating" as they write about on the website
i noticed that in my error thing tho it seemed to generate populators by chunk
lol
@tender shard was making one earlier
proguard is the most allowed obf
Anything beyond that isn't really allowed at this point
And even some proguard settings are not allowed for free plugins
Mm kay, thank you
I dont need an obfuscator, I just write my code all in one class, thatll do it
Massive brain
one line
"Error on line 1"
i think there actually is a website smwhere that flattens scripts automatically
imagine I did that on my 10k line plugin
dont remember the url tho
It would be fantastic, imagine updating that
i swear making only ONE entity glow is impossible
private does nothing lol
I would not
why does mojang
Ahh, I see
?
?
not sure what you mean as I am able to do that easily
one entity glow for one specific player?
for one player?
yes
thats different
i dont get this protocolib shit
why cant i just make the packet
sned it to player
cant find the website, should i make one?
why they gotta make it difficult
remind me, what website?
sadly no. my plugins dont use packets yet
it was someone's github.io and it had a flattener for java, js, json, etc.
just write a script which takes out all \n
especially those
what does only "return" do
while(true){
if(case.equals("1") {
return;
}
}``` Like this
stops code execution within a void function
yeah
if case equals "1" then itd stop running the code in that function
Well, that wouldn't compile because "case" is a keyword, but if it were any other word, yeah
^
Depends on your checks. If it’s just null before any check, then the item is likely just air
Can you share your code?
difference between break?
interact btw is called for both hands for stuff like right click
so if your offhand is null, you'd see that here
Stops a loop.
return does not?
It does, but it also has ends the method.
Break will just stop a loop and continue with code execution beneath it.
Return is the exit point for a method. So if you return in the middle of a loop. The loop will stop and the method will end.
can i use while loop in while loop
Yes, but you need to be careful with while loops.
how could i check if argument in command is number?
i tried
if(choose == 1) {
obs.startRecord();
isEnded = false;
}```
Well that looks fine. Is it not being reached?
its spamming eternally
🙂
umm do i need to keep going or what
Oh, you are checking to if your value is false. Then setting it to false in your loop.
Hence it will never stop.
Set the values to true or invert the check.
Can addItem() add more then 1 item at once?
yes acutally i passed this phase , it breaks the loop
Or do i need to for loop X times on addItem
So all is good then?
actually i want to enter another loop
Then add one? Or make a method that has a new loop.
i believe there’s a method to add an array of items
Different items no, the same item yes. However it’s done with the itemstack class and not with the #addItem() method itself.
varargs 🙂
If you know the amount that needs to be given, you could set the amount on the itemstack and then just give them the itemstack instead of looping.
to send an entity metadata packet with protocollib what are the necessary fields to update
if(!args[3].equalsIgnoreCase("s") || !args[3].equalsIgnoreCase("b")) {
player.sendMessage(ChatColor.GREEN + "Dozwolone typy sklepów to b(kup) oraz s(sprzedaj).");
return true;
}
player.sendMessage(ChatColor.GREEN + "Utworzono sklep.");
}``` why when i type b or s plugin is still sending a message about correct shop types. Should not this if statement just get skipped?
it’s not an else statement
how can i get a player's UUID that has never played before?
or the player's info like name, uuid
getOfflinePlayer
no as in they have never loggedi n
yes
i thought offlineplayer was for people who have logged in before
or is it every mc account
how do i check if a player exists from just a string (name)
so if i create a method like isPlayerExist(String name)
Bukkit.getOfflinePlayer(name)
deprecated though
you mean if they’ve ever logged in before?
It will still always return a player whether or not they exist
yeah it’s wack
If you want to check if some name exists and has an account, you'll have to directly query Mojang API
Or, I suppose, Microsoft API
Probably but not for long
public String getUUIDFromName(String name) {
Scanner scanner;
try {
scanner = new Scanner(new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openStream());
String rawData = scanner.nextLine();
scanner.close();
return UUID.fromString(rawData.split("\"")[3].replaceFirst("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)", "$1-$2-$3-$4-$5")).toString();
} catch (IOException e) {
e.printStackTrace();
}
return "not found";
}```
thats what i have for uuid
i didnt make that code
does it work?
came across this random src on my pc and am trying to fix it, its using (oh god, people are gunna get mad) 1.7 and its trying to do some silent check, and its just not working. ((CraftEntity)entity).getHandle().Silent = silence;, Silent isnt a boolean nor even exists. why did i decide to do this
Any reason you're still using 1.7 though? Are you updating it from 1.7? If so, Bukkit has API to set the silence value of an entity
entity.setSilent(true)
yeah no i dont feel like updating this dinosaur lmao
im just messing around with it cause fun
even worse though some of it when i imported into intellij was using java 7
i mean im 99% sure its some mineplex code from a leak i got ages ago, so it would explain it.
well, given the project literally says mineplex i think it is lmao
how can i run main via maven
is this not how i would store properties in yml??
but how would I read this data and create an object with each
like zorro will be a rank with given multiplier cost and blocks as a list
this is how to create the rank but how can i gather these data from the yml
to actually put it in as parameters to make the ranks
FileConfiguration#getConfigurationSection(“ranks.” + playerName).get(“value”)
also not a good idea to make config based on player names, use uuid instead
what does this do
exactly
gets a value from the rank
ok but how would i make the blocks work
etc #getInt(“multiplier”)
because i need a list of blocks for each
well you’re storing them as a map, not as a list
no
use getMapList if you want the map
also this
so for liek 1st one
Material.valueOf(blockName) (not sure if it’s case sensitive or not)
actually no
ah
ok then yeah use that
is that even valid yaml?
ye i think so
i would make each rank a configuration section, not a value of a list
how
did you create this yaml manually or did you program it?
manually
yea
ye but below the second rank is wrong i know that part
wait ill send only first 2 ranks
ranks:
- name: zorro
multiplier: 1
cost: 40000
blocks:
- name: stone
prob: 0.6
- name: coal_ore
prob: 0.2
- name: iron_ore
prob: 0.2
- name: gold_ore
prob: 0.2 - name: xylia
multiplier: 1
cost: 70000
blocks:
- name: stone
prob:
- name: coal_ore
prob:
- name: iron_ore
prob:
- name: redstone_ore
prob:
- name: lapis_ore
prob:
- name: redstone_block
prob:
- name: lapis_block
prob:
why tho
what does that even mean
it’s not a configuration section
idk what that means 😆
so it can’t have properties like that
huh?
but then i cant define what is the name
of the rank
can i
that is what i had initially
like this
does this work
and i have each block: so i can add probability
liek oak_log: 0.1
can i do that
can I explain this clearly so u can help me, never done yml
so might need some help
if u dont mind
ok i got it liek this
but why does this not work
Think?
on your right side there should then be a maven tab
open it and find the package goal
double click that and it should package your jar
can someone help me with reading yml file
What is your problem?
I can't be bothered to real everything you've sent before lol
so this is my class for ranks
Yeah?
And what is not working?
i just dont know
how to read the yml
to store these data
in the class
or implement rather
its your storage class right
To read for example the willow multiplier you would do like config.getInt("willow.multiplier") or whatever the full path is
That is all
YamlConfiguration.loadConfiguration(new File("path"))
^
Iterate over all ranks
ye but like
xd
And get all values in the loop
how do u get "willow"
yaml is section based language
get new section then loop it
for(String s : new String[] {"willow", "vero"}
he should register them on config
Or just do for(String s : config.getConfigurationSection(SomePath).getKeys(false))
Depends if you have all ranks in the config from start or not
its a bad code
If not, use the first option, otherwise the second
just listen @tepid ore
aight ty guys
can i ask more question if i get stuck again
Ofc
❤️
anything i cann code
wats that
ehhhh
ohh
Ranks.willow.multiplier or whatever
ohoh
Guys do u know any good tutorial playlists that is good for learning Spigot?
i thought u actually meant the file path
Also, do for(String rank : config.getConfigurationSection(YourConfigPathToRanks).getKeys(false))
Oh, nono
I started with this iirc https://www.youtube.com/watch?v=r4W4drYdb4Q
Howdy all and welcome to my all-new series for Plugin Development! New videos every Monday. Join my discord for help and more :)
Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers
Download Java Jre: https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
Down...
Pretty good imo
Do you know Java?
Otherwise, start with that
Yeah
Then watch the tutorial 🙂
Alright thanks bro
Np
Also, you can ask here if you need help 🙂
Yeah might be it lol
What is it?
with probability
so the double numbers
are probability for each block i want
but is this a bad way of writing this
I would just do a list, with the blocks and then the odds after a comma
But yeah
That works
I would suggest a list as it is easier to edit and read imo
because this way just like "zorro" "serenity" i would need to search by block name right
how can have them in a list here
You can do config.getStringList()
add a hyphen before the block name, and remove the :
oh alright
its better than list
I prefer a list, but whatever works
Yeah
Mhm
where do i find itemstack version list?
making yaml manually is not a very good idea
to why
Wat?
did you hear xmaterials
meh
i think your solution is it
then might as well keep it like that
my plugins supports only latest and prelatest
since my whole yml is liek that
xmaterial is cross platform itemstack parser
Sounds good
Though
If you want all materials
ikr
its made in code, the file
then you don't need this ugly usage
it serializes the inventory or whatever
is it a database
its a yml file
config
okay then xmaterial is better
meh i dont need that
but your choose
i just wanna know the 1.17.1 itemstack version lol
okay i understand you
?paste
ik
wait how do i loop them without writing each name of the block
to find each name of block
soo like where the version comes from?
i kept it like this
btw this is the error
java.lang.IllegalArgumentException: Newer version! Server downgrades are not supported!
it screams that version is too new
good question but did you complete everything except that
that is why other methods are made
ConfigurationSection#getKeys
what would blocks: be
cus its not Int
but does it count as string
if like that
idk yml bruh
double
huh
no i had blockname: block_odds
im not hardcoding blockname for each rank
so how could iget blocknames as a list
if its a key
yes as i said above
config.getConfigurationSection(path).getKeys(false)
yaml is section based language
btw its 2730 if somebody wanna know
oh ok i got it now
but what is boolean deep
for the getKeys method
section1:
deep-section:
another-deep-section:
section2:```
so i put true
wait what
im getting the keys under blocks:
so im getting the block names
and i can also use these names to get probabilities
no you didn't understand
firstly you should loop rank names
rank1:
deep-section:
rank2:
rank3:
and get section of the a rank
serialize the section
can i use anydesk
lolol
not rly
but im guessing its whatever comes before :
section is it
yes
ya i get this
but all sections includes under sections of itself
their parent is blocks
good
blocks' parents is ranks
config.getConfigurationSection("ranks." + s + ".blocks")
where s is a given name of a rank
Yeah
do you want store their proabilities as list
i guess yes
okay then create new method
which is returns list
the method will need configuration section parameter
static public ArrayList<Double> probabilityList(ConfigurationSection section) {
ArrayList<Double> probs = new ArrayList<Double>();
return probs;
}
good
i didnt check it
i dont have any errors
where is it
is this valid
wtf
whats problem
i’ve never seen static public before
They can be in any order, yeah
i teach him config sections i dont i care static and public keywords
i talking for her level
<3<3<3
If you really want, you can do strictfp final static protected void hello()
huh
No, please don't do that. Just making a point lol
this is a util method
so you should make static it
but not public
make it private
alr
loop blocks section and add probabilities to the list
but you need map to make it
no
it’s a string
List<Double> probabilities = section.getKeys(false).stream()
.map(p -> config.getDouble("ranks." + p + ".blocks." + x)
.collect(Collectors.toList());
what is he trying to do with these probabilities?
that comes later
this is another usage of your for loop
making prison server
you can get it as a Map simply by get the section, cast to MemorySection and .getMap()
completely same but its one line
yuh yuh i get that i get that
one expression * 😎
yeah actually
what does -> even do
i can write all classes in one line using java
in java
lambda
@radiant cedar Is there a reason you want a List of probabilities?
no xd
for each rank of mines
dont need i will just use 2 arraylists like a noob
it seems odd to want it in a List where you need a key
void take(Consumer<Integer> consumer) {
consumer.accept(1);
}
//
// myObject.take(i -> System.out.println(i));
myObject.take(System.out::println);
.getKeys returns an array of strings right
a simple Map would be more useful
move your cursor to the method
you can think Set = arraylist
oh ok
a list w/o order and w/o duplicates
matchMaterial is preferred
I'm checking if the specified item has persistentdatacontainer i want but its not entering
p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(Main.plugin, "phone-data"), PersistentDataType.STRING)
public PhoneItem() {
ItemMeta meta = phone.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Main.plugin, "phone-data");
container.set(key, PersistentDataType.STRING, "PHONE");
phone.setItemMeta(meta);
}
I want to make a plugin that creates a config file for every player, but I don't really understand how all this work.
public class ItemManager {
public static ItemStack Phone;
public static void init() {
createPhone();
}
private static void createPhone(){
ItemStack item = new ItemStack(Material.PAPER, 9);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Phone");
PersistentDataContainer pdc = meta.getPersistentDataContainer();
pdc.set(new NamespacedKey(Main.getPlugin(Main.class), "phone-data"), PersistentDataType.BYTE, (byte) 1);
item.setItemMeta(meta);
Phone= item;
}
}
this is worst idea
Will it take too much storage.
no
purpose of database is storing datas in one part
multi yaml file databases is a lot of issues
for example you cannot load them in startup
ha, it was my solution for avoiding 800MB of yaml
well not yaml
a cheaper format
i recommend sqlite
from my experience using yaml files as a database is very bad and tedious
I'd suggest however doing this:
Use PDC if you don't need much storage
If you need to act on offline players, store an action that you can run when they join in a file (such as: REMOVE, ADD, SET)
i would recommend sqllite like he said or just an actual database
or pdc if it’s small enough
but i don’t think that’ll work if you’re making it multi-server
Redis + AOF
fastest and most efficient way for single key-value pair storage
if your server is not hypixel
probably you dont need it xd
but you can. of course.
ofc
but for a simple key-value pair look up its more than enough
player.getInventory().getItem(i).hasMetadata("test")
Cannot resolve method 'hasMetadata' in 'ItemStack'
player.getInventory().getItem(i).getPersistentDataContainer().has(key, type);
you want that?
ye
.
metadata of itemstacks is nbt
that's not even what i'm trying to do
ohhhhhhhhhhh
or aak persistent data container
not the worst but not the best. you can choose .json over .yaml if you cannot deal with database to store player data
how can i disable redstone placement. this doesnt work
can you send the full event?
the rest of if's work tho
except redstone
kinda shit code but yeah
also registered it on main class in onEnable
make a list
e.g. banned components and check if the material is in the list
i didnt ask about code efficiency, but why doesnt redstone work
what version u on
if(bannedComponents.contains(Material material){
e.setCanelled(true);
}
whats not working
hey to check if the player is online do i just make an if statement and check if Player is null?
ye
aight cool tyty
just Material.REDSTONE that if won't trigger?
yes
that means redstone isn't being placed you could figure out the correct material if you just do a simple sysout(mat)
usually I do that if i'm not quite sure
simple debug statement should clear up if you got the right material comparing
ah kk ty for the ifno
info*
im trying to make a mineplex-style core plugin because im bored, its not gunna go well but why not.
ty ;D first proper plugin that im actually going to use lmao
how can I add a new variable and method for the Player class
so everyone can have a rank and money variable
oh
really?
i find java easy but kotlin a little confusing
granted though my only experience is android apps so.
kotlin has a higher learning curve but a lower starting point
not a good reference point lmao
it’s probably easier to learn a small amount of kotlin than a small amount of java
but harder to learn a lot of kotlin than it is to learn a lot of java
i mean if im honest i find java somewhat easy
sometimes its really confusing but like right now it isnt bad
i mean i just learned what a constructor is so thats nice
btw is ur pfp a crab deotime?
lets go
wait if i use mongodb for storing perms can that handle a hashmap for my permissions
infact how tf do i make a hashmap for it he bukkit wiki doesnt really get into that
nono
it says how to make one
Map<Object, Object> x = new HashMap<>();
but i dont get how i would add to one through my onjoin event
and how i would make one globally avalable because i have an instance thing but thats static
whats the difference? ive used neither ;D
I am an API dev, I already made that mistake a few times - not so great to refactor afterwards
^
yes but what is the difference between a map and a hashmap i dont understand that
you always use the lowest level contract for field types
they sound the same
ah ok
It groups things by their hash to minimize the number of equals calls
Uh
yeah, that being said hashmaps are not the be-all-end-all of collections
Not compared to Map, you can’t make a Map
Map is just a set of methods a class must have to call itself a Map
i have now learned what an interface is, useful.
There are multiple implementations like TreeMap, HashMap, LinkedHashMap, ConcurrentHashMap and etc.
interface Animal {
void speak();
}
class Cat implements Animal {
@Override
public void speak() {
System.out.println("meow");
}
}
//
Animal animal = new Cat();
animal.speak();
They are nice and all, but sometimes they are too much care.
But then I am also a particularly lazy person
my mum loves cats but i like both
cats look cute
and dogs are better at most other things
im watching a yt tutorial for mongodb and java and the guy said the program isnt going to work until i compile it
like yeah bro imma go run raw java code rq 1 sec
People are doing too much python/lua/javascript/etc these days
yes well
e
the guy told me to make the mongodb client and stuff in the onenable, how tf am i gunna access that outside the onenable
can i just make it private static outside the onenable and then make a thing to getMongo()
i got this far
where x is the users uuid
but if there is no entry for that player
how can i make it so the code can make a new key with the
uuid
so then i can add a key for ranks and money to that
@fleet falcon
huh
like this
ye ik the path dosnt exist
i have different method to check
but how can i add
nono but what if that "players."+ x doesnt exist
how can i make new
what that x
ohhh
ok thats so good
hey how do i add my permissions to the db? it would be kinda dumb to do a hashmap with player,permattachment and im not sure what else to put there
tyy
yeah well in general what would i store,
because i got the id stuff alr set i just need a way of storing all the permissionsattachments
wait no shouldnt i store a list of strings with all the permission nodes then for each when a player joins add that to the permission attachment?
how do i store a list of strings?
not a hashmap since that needs 2 things, just a straight list of all of them
What are the benefits on making an inner class static? I assume the class is loaded and stored just like a static function, but anything apart from that?
back in the old days...
Java was hipstery type of programming lang too in the 90s
inner private classes are almost always static
because they have no reason not to be
That is true
if you make inner class static you dont need to initialize the outer class in order to construct the inner one
Also, did you know that there are CPUs that can execute Java bytecode? So theoretically Java is a low level lang these days.
package me.person.javastuff;
public class Main {
private class MyClass {
void doSomething() {
System.out.println("Hello World!");
}
}
public static void main(String[] args) {
new Main().new MyClass().doSomething();
}
}
its so hideous
isn't it new Main.MyClass().doSomething()
suppose you have a inner class in which you want to use private outer class fields without providing for people to directly access the public fields
if the inner class is static
