#help-archived
1 messages · Page 67 of 1
if you're doing that you might as well just use a list of pairs
i noticed you cant check for perfect match
you cant just use get(itemstack)
dude i am using a list of pairs
then use a list
if the itemstack is same item but with less/more amount
dont use a hashmap
I am linking a list of pairs to an itemstack
contains will return false
entry.getKey().isSimilar(itemstack)
if you're doing this, using a hashmap is pointless
i aggree
;-;
tbh there are many ways wich work
what would I use instead of a hashmap
so its not that big of a deal
using List<Pair<K, V>>
0-O
it works but its pointless @vernal spruce
but you dont need to
dude
youre gonna accomplish the same exact thing
@boreal tiger its really not a huge problem
its basically the same amount of code
it would turn into Pair<ItemStack, List<Pair<ItemStack, Double>>>
I can't deal with that shit xD
its not about the amount of code
i understand that
lol
let the man use a hashmap
but its wrong xD
you can not use oop and accomplish the same thing
my guy, defending incorrect use of hashmaps
but your maintability is gonna be worse
imma head out
because
what are you trying to accomplish again?
because you're iterating over it. the point of a hashmap is that you can~get stuff without iterating
^
A crate opening system. I am linking a crate to a pair of ItemStacks and weights
because you're iterating over it. the point of a hashmap is that you can~get stuff without iterating
@boreal tiger well that;s the thing. I didn't realise I would have to iterate
yeah thats fine
my plan was that I could pass an item in from a listener
and use map.get(object)
yeah I get that
yea at this point
and it would give me the corresponding list
yep
and make a crate object
I have a crate object...
n i c e
lol
good job, you should use that
in your crate object have a List<Pair<ItemStack, Double>> as your weight list
this is my crate object
that link is blank
ehm
another
that is the default website link
blank link
oops
my plan:
A crate is an item stack which has certain parameters already defined.
The things which are the same amongst every crate are:
The namespaced key, which will be used to identify when a crate type is right clicked.
The inventory which will open (however, every player must have their own crate inventory)
The lore of the crate (Might be made customisable)
The material (will always be a chest)
The colour of the name (subject to change)
When a crate is created, it must given a name and a list of pairs(itemstacks and weight). During the process of creating the crate, the crate itemstack and list of pairs (ItemStack and weight) will be added to a hashmap. This way, it will be possible in an event listener to get the item in the player’s hand, pass it to the hash map, get back the list of weighted itemstacks, open a standard Inventory, and then run the contents of the inventory through the GUI.
eh that's not really how objects works
lol I tried
let me look one moment and give some tips
why do you have a static final crate object
so for the bungeecord plugins folder, is that olnly for plugins that I want to be spread across the servers?
oh
the crate is an ItemStack
what if i want luckperms to be applied accross all the servers
put the plugin in all servers
that is the only static variable you should have
all the others need getters and setters
this is the wrong use of OOP
your class should have a constructor
ok so
I originally started doing that
but then
I didn't see how i could do it
without extending ItemStack
cause it's an itemStack right
nope
how am I meant to have the properties of an ItemStack
you dont
without it extending ItemStack
but I need to use it as an ItemStack
right
a crate is an ItemStack
no its not
but...
listen
waaah
I haven't really got a clear idea of your plugin, but I think:
- you should create a 'Crate' interface with all the methods and make implementations of it
- A crate object should represent the possible items that can be found, each with its specific odds (supposing you are making a crate drop plugin if I understood correctly)
Itemstack icon, ContentsList weights, String name
fedi even youre overcomplicating it a bit
interfaces dont need to be used
🤷♂️ I'm used to them, if he needs just 1 crate prob. not
so for server owners. They can just make a crate
an interface is for referencing multiple similar objects but that have unique properties
(also the job of abstraction which is beneficial in its own way)
anyways
your constructor should look something like this
if (!(sender instanceof Player))
Then how do i get its location
you dont
so if its a command block
ah
CrateItem(String name, ContentsList weights) @formal nimbus
in your constructor create the item that you want, and set the field icon as that item. then make a getter getIcon
somewhere else have a list called List<CrateItem> crates
and then when you want to test it
iterate over that list
and do
wel
crateItem.getIcon().isSimilar
your brain will thank you later on
hopefully
lmao
how do i get if a Command Sender
is a command block
or a function
???
if (!(sender instanceof Player))
@wanton delta
and then get the cmd blocks loc
cant
the command block either executes as a player or as the Server
also just a question
@wanton delta yes?
bukkit will think it is being done as a player
oh
as a universal crate identifier
PI -.-
can i get the world a command is being run in
Pl?
no he said command block
technically some entities implement CommandSender
(but this in general sounds fishy, you shouldnt be using vanilla commands)
you cant use execute on a non-entity sender
@wanton delta as in execute as the player
dont set it as final
it's not correct
@hollow thorn you can check if the sender is a commandblock, is that what you want?
?
p sure all entities can be senders
@hollow thorn you can check if the sender is a commandblock, is that what you want?
@boreal tiger how do i cast it into the varible
It's a list of pairs<ItemStack, Weight>
you want to cast the sender to commandblocksender?
so Weights isn't right?
kk
wdym 'how do i cast it into the variable'
attlantiz i meant that you cant use the /execute command on a non-entity sender
he didnt ask that though xD
i know
so if i use an execute
he said that
i got confused
but this whole idea seems
fishy
commandblocks are a big nono on spigot
well like
and it doesnt matter
🤷♂️
why would anyone use commandblocks
^
ahah bruh imagine programming with Bukkit API, just make the server use command blocks
"commandblocks are a big nono on spigot"
I just dont get this xD
you shouldt use commandblocks if u have a spigot server lol
heck not even on vanilla nowadays lol
there are many problems with command blocks
what does the datapack have to do with the command block xD
youre misunderstanding me
I'm not
datapacks are pretty much commands, right?
im saying commandblocks are basically obselete no matter what server youre running
has anyone here worked with GSON ?
Do you know if it's possible to make text "beautified"
it sucks to have a 1 line
i was just saying on vanilla, you should avoid commandblocks
why?
Mostly, maintainability. It's far easier to maintain a simple listener plugin than a command-block monstrosity.
datapacks do the same thing
New GsonBuilder().setPrettyPrinting().create()
datapacks are not commandblocks xD
Command blocks will hold you back significantly if you invest in them.
yeah its easier but you dont know what he's using the command block for
you obviously dont understand what im trying to say lmao
I dont
if you have a command block setup that is meant to run all the time, you should use datapacks instead
you're confusing datapacks with command blocks and creating an unecessary argument
it really wasnt that serious
Yeah gson pretty fire
I spent 4 hours trying others but they were just making me waste time
with adapters and all
another thing- my first server came with plugin metrics, but my other servers didnt. Should i copy and paste plugin metrics into all of the plugin folders?
no
n
whats plugin metrics for?
i believe some plugins use them to keep track of their stats
yea
that
so copy and pasting wont do anything
whatever plugins use them will generate the folder
oh ok
could someone help me with my prison server really quick ?
🤷♂️
so im getting a bunch of (ip) <-> InitialHandler has pinged
I am gonna do stuff with contents
in my bungeecord console
etc
what does that mean?
@wind dock that happens whenever someone clicks the refresh button
@formal nimbus you dont need the crateMeta field
i think thats obselete
oh rlly
like i said i strongly recommend to just replace ContentsList with the list-pair
and if you want to add something to it or change it create a getter/adder
yep
right so
hmm
so kind of like what I've done in the ContentsList
but it's a field of the Crate object instead
so it's kind of like merging them
into one new incredible being....
youre just getting rid of the contentslist wrapper you made
and just using the "raw" object so to speak
I prefer the way I phased it
so youll have a new field
but yes
List<Pair<afasou>> weights or something
yah
the weight of each item is part of the pair
but yee
gotchu my bwoi
however
Isn't there an issue in that this is now a nightmare to understand?
I mean we got this going on
private Pair<ItemStack, ArrayList<Pair<ItemStack, Double>>> id;
cause I've gonna replace the hash with a pair
but it's like
yeesh
I guess I'm just going to have to annotate
so I'm checking in another class if it has a certain name when trying to run the command it doesnt work even if I hold the item
ItemStack Class
ItemStack harvesterhoe = new ItemStack(Material.DIAMOND_HOE);
ItemMeta harvestermeta = harvesterhoe.getItemMeta();
harvestermeta.setDisplayName(ChatColor.GREEN + "Harvester Hoe");```
The class I'm trying to execute the GUI in
```java
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player) {
Player p = (Player) sender;
if(p.getInventory().getItemInHand().getItemMeta().getDisplayName() == ChatColor.GREEN + "Harvester Hoe") {
Inventory inv = Bukkit.createInventory(null, 9, ChatColor.BLUE + "Harvester Hoe Upgrades");
ItemStack doubleup = new ItemStack(Material.YELLOW_FLOWER);
ItemMeta doubleupmeta = doubleup.getItemMeta();
doubleupmeta.setDisplayName(ChatColor.GREEN + "Double Up");
ArrayList<String> doubleuplore = new ArrayList<String>();
doubleuplore.add(ChatColor.GRAY + "Doubles the ammount of sugarcane you harvest");
inv.addItem(doubleup);
inv.setItem(0, doubleup);
p.openInventory(inv);
} else {
p.sendMessage(ChatColor.RED + "You must have a harvester hoe to execute this command");
}
}
return true;
}
}
}```
any help is appreciated
First of all make it formatted right. Second use implicit else when possible. What do you mean by execute the gui?
Open it?
yea its supposed to open the GUI
and it doesnt?
well first of all
We don't compare Objects with ==
use String.equals(String)
or even String.equalsIgnoreCase(String)
^Will ignore upp and lower case
so "hi".equalsIgnoreCase("Hi") would return true
When does 1.16 release
thanks
@wanton delta I have a different issue now
I've basically moved everything into the crate object
actually
nvm
I think I have a solution
sorry for the ping
so for the bungeecord server
I have the bungeecord port aas 25565
as*
but the hub is 25566
when using a subdomain
which port do i set it to?
you would set to 25565 yes
because you wnat them to join through bungeecord
make sure they cant use the other ports
hey, can anyone tell me why JetCobblestone.BasicCrate.getItemStack() returns null?
BasicCrate is null most probably
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player) {
Player p = (Player) sender;
if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Harvester Hoe")) {
Inventory inv = Bukkit.createInventory(null, 9, ChatColor.BLUE + "Harvester Hoe Upgrades");
ItemStack doubleup = new ItemStack(Material.YELLOW_FLOWER);
ItemMeta doubleupmeta = doubleup.getItemMeta();
doubleupmeta.setDisplayName(ChatColor.GREEN + "Double Up");
ArrayList<String> doubleuplore = new ArrayList<String>();
doubleuplore.add(ChatColor.GRAY + "Doubles the ammount of sugarcane you harvest");
doubleup.setItemMeta(doubleupmeta);
inv.addItem(doubleup);
inv.setItem(0, doubleup);
p.openInventory(inv);
} else {
p.sendMessage(ChatColor.RED + "You must have a harvester hoe to execute this command");
}
}else {
}
return true;
}``` when the item i hold in my hand is not a harvester hoe it gives me an interneal error any idea's on fixing because i thought the else statement would fix it but apparently not
@formal nimbus can you send your full main class and the class where you call JetCobblestone.BasicCrate.getItemStack()
yep
@hallow surge you're trying to get the meta of an item that might be null
oh i have an idea on a fix
p.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Harvester Hoe")
You need to check if itemInHand is null before getting the meta
main
public static CrateItem basicCrate; is null
@formal nimbus
you're not assigning it
CrateItem basicCrate = new CrateItem("Basic Crate", null);
this is a local variable inside onEnable
isn't the = new assigning it?
CrateItem basicCrate
You're making a local variable
you should probably have your crates in a list or something though
or even make something like a CrateRegistry class to handle that
something like this attlantiz
java if(e.getCurrentItem().getItemMeta() != null) { //code here }
not quite
you should check if the current ite mis null
if (e.getCurrentItem() == null) {
}
that would be null if they dont have an item in their hand
also quick question with Item lore haven't worked with it before how do you add it to the stack
oh i found out
you should probably have your crates in a list or something though
@boreal tiger yeah I have a list
nvm
@formal nimbus why do you have that static crate then xD
public static CrateItem basicCrate;
oh
I haven't made something to create crates yet
so I've just done it in there
to test it works
ah right 👍
which atm it's not
for some reason none of the stuff is being assigned
and it's giving me just a normal chest
Who has a /spawn plugin
I would like there to be a delay before the teleportation and the teleportation is canceled if the player moves
Also that the player is not spawn when he joins for the first time or when he dies
./spawn plugins aren't hard xD
just look it up on google
there is bound to be one
essentials spawn
I have been searching since yesterday :'(
I had a perfect one but it crashes when I change the message.yml however on my old server it worked
i don't like essentials spawn because i have to download essentials too
i sought
@tawny crescent what you want the delay to be
5 seconds
hi I'm having issues with changing the color of a players name received from an event listener.
ChatColor.DARK_GRAY + ChatColor.BOLD + "] " + ChatColor.GOLD + event.getPlayer().getDisplayName() + ChatColor.GOLD + " has started a 1 hour 2x mcMMO experience boost! " +
ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "[" + ChatColor.RED + ChatColor.BOLD + "!" + ChatColor.DARK_GRAY + ChatColor.BOLD + "]");```
I've set the color to gold before event.getPlayer().getDisplayName() but when ingame, the colors are correct for the rest of the message except for the players name, which is just white.
I might just be overlooking something simple but I don't know lmao
put speech marks inebetween then ChatColor.GOLD and the event.getPlayer
so ChatColor.GOLD + "" + event.getPlayer...
@cerulean snow
Also
could somebody try and figure out which the ItemStack isn't returning correctly?
Describe
sorry
dicord laggede
ok so that's my crate class
this is my main in which I make a crate
this is my command to get a crate
when I use the command
I just get a normal chest
not sure why
Is it possible to change default world while the server is on?
So whenever player joins, the player must spawn in default map as we set
@chrome edge I think you can change those setting with the Server object, but it's easier to just teleport the player to the world you want in PlayerJoinEvent.
@cerulean snow Consider using ChatColor.translateAlternateColorCode method instead of concetenating strings and enums.
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
So basically, I made my own script and uploaded it too spigot, but how would I change the link to it since I want to update it?
script?
what is that
A language
uh
Can a staff member change my name on spigot its been 3 days
Yea
do you have the redstone thing
so how would I update the link to one of my spigot plugins
Yes
you need to update the resource arlists
He changed it on spigot lol
@frigid ember have you change the name in your settings in your profile
How would I do that?
i already requested the name change
Martoph how do I update the resource?
Well, Greg once changed on spigot dm a forum staff and they will assist you with a change on here as well.
Its fine i emailed him
fastest way
no lmao
omg
how do I get there lmao
its not faster
Hello, my scoreboards work but it's not in descending order and I need a condition to say that
if (Bukkit.getPlayer(name).getStatistic (Statistic_PLAYER_KILLS) > to others){
then put the one with the most kills first
}
They dont do name changes
Martoph what should I click to get there?
Well yes they do
Martoph Dont tell people what to do my guy
oooo
Grek they do name changes
greg, if you were a lead of a project that has thousands of clients
would you want someone to email you about a name change?
^
Now what, I am on the edit resource?
On discord yes?
its a name
when he gets to it
lmao
i doubt he'll even do anything after seeing your email
^
Martoph should I post resource update?
donated 10 dollars for a name change lol
Omg Greg if it's on spigot be patient
@wheat forum i dont know
greg go through the process like everyone else lmfao
i paid $10
waited around a week
Once changed their just ask a forum staff here to change it on discord as well
stop acting privileged
Its all good he will get my email
whatever
Posted this about 25mins ago but haven't got a reply, so will post again as it has been buried:
https://hastebin.com/axojokovah.cpp
ok so that's my crate class
https://hastebin.com/pikuvemipe.java
this is my main in which I make a crate
https://hastebin.com/ofoviqacut.java
this is my command to get a crate
when I use the command
I just get a normal chest
not sure why
yea he'll read your email probably after he changes ur name lmfao
Conclure im in agreement with you lol
@formal nimbus youre not describing your problem nicely
we have no idea what youre trying to do
i was just saying like "some dont have access but they can find someone if not when you ask them once they change it"
Sorry - I'm trying to get a special chest which has a name and a lore
it has some other stuff to, but the ItemStack doesn't seem to be creating properly
I said "once changed on spigot you can dm a staff here to change it on the server as well"
I just get a normal chest when I try to give myself the ItemStack
oh lol
Hi guys, does anyone know where the actual logic code of explosions is located? Cause everytime i try to find it in the bukkit source it just shows me interfaces, but im looking for the implementation of those functions
ah yes
CraftBukkit?
ItemStack#setItemMeta
ItemMeta meta = item.getItemMeta();
👌
ItemStack#setItemMeta(meta)
and open net.minecraft.server.v1_15_R1.Explosion
Intellij
i have no fucking clue what ide they use lmfao
Buildtools will decompile for you
i use intellij
Jet yes
when you open the explosion interface
thanks 😄
cerrealic you can right click the class/interface name and operate "Find Usages"
not even that
Huh?
If he want to locate where the java file is being used that's how you do it lmao
How do I update my spigot plugin link??
Sure he does ?
@formal nimbus That code will not work
i dont have nms dependency
add it
@formal nimbus That code will not work
@silent veldt :0
How do I update my spigot plugin link??
@formal nimbus You have to create a reference of the copy
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
then set the item meta of the stack back to the modified meta
edit that copy
thx
@formal nimbus You need to store crate.getItemStack as an ItemMeta object then modify that
wait what but thats just spigot api
and set it back with crate.setItemMeta
no its not
oh. I was told that was obsolete
spigot-api and spigot are different
oh yeah
ItemStack item = new ItemStack(Material.DIRT);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("dd");
item.setItemMeta(meta);
org.spigotmc:spigot is installed by Buildtools
Every time you do crate.getItemMeta, it's getting the item meta, modifying it, and throwing it away
I've tried a bunch of different things but the players name still prints out as white instead of gold
right
it's not a getter really, it's a copier
@hearty trellis you can use that to navigate
JC it's smart to have some type of itembuilder
to net.minecraft.server.v1_15_R1.explosion
ItemMeta im = crate.getItemMeta();
im.setLore("My cool lore");
// other modifications to im
crate.setItemMeta(im);
setLore requires a List<String> ?
Yeah, it's just an example
if it needs a list, give it a list
Of how to do it
Arrays.asList("line1", "line2")
How do I update my link to download my plugin???
JetCobble, that's better
sweet
although I'm not sure why you call getPersistentDataContainer() right there
@formal nimbus Yup. That will work.
Also, he's right about setLore
It does require a List<String>, so just surround your text with Arrays.asList as he suggested
is there a good way of downloading plugins on a remote ubuntu box, I've been trying to wget/curl directly from the forums however I've been unsuccessful - additionally I cannot find a way to create an embed link on either Google drive or Onedrive
You are creating a List<String> in your code, but never using it
How do I update my link to download my plugin???
no, he's using it
Else do something like this
class ItemBuilder {
ItemStack item;
ItemMeta meta;
public ItemBuilder(ItemStack stack) {
item = stack;
meta = stack.getItemMeta();
}
public ItemBuilder withLore(String... lore) {
meta.setLore(Arrays.asList(lore));
return this;
}
public ItemStack toItemStack() {
item.setItemMeta(meta);
return item;
}
}```
```java
class OtherClass {
//Some EventHandler
ItemStack stack = new ItemBuilder(new ItemStack(Material.DIRT))
.withLores("loreline1", "loreline2");
}```
@wanton delta nms is not hosted tho, there's no spigot folder to get the dependency from
so how the heck did you manage to do that
You're right, he is
like I said, BuildTools will install the org.spigotmc:spigot arifact
That code is good
Shoot
Specify
shuffle?
like I said, BuildTools will install the org.spigotmc:spigot arifact
@marsh nova ah so i just need to shade it, or flatdir it or somehting
I'll explain it and post the whole class so it makes more sense
no dont shade it xD
lol
lmao
lol
compileOnly is enough
lmao 😂
provided is better
Does it exist in gradle?
otherwise you get dependency hell in dependent projects using different spigot versions
the shuffle function is supposed to open a generic crate inventory.
it is then meant to take the items out of the crates contents list
and move them across the screen
in a scrolling GUI
plugin A declares spigot 1.15 as compile, plugin B uses spigot 1.12 -> no good. That's why you use provided for spigot
each item in the crates contents is paired with a weight
what would the manager do?
maintain the crateList
im using gradle tho, no 'provided' i think
@naive goblet I'm using ChatColor.translateAlternateColorCodes but its still printing in white
ChatColor.translateAlternateColorCodes('6', event.getPlayer().getDisplayName() + ChatColor.GOLD + " has started a 1 hour 2x mcMMO experience boost! ")
what do you mean by maintain?
nothing special or technical
switch the first 6 to &
how would thing provide me the id of a crate provided a similar item stack in a player's hand
just hold the crateList, find crates by id, add crates, etc.
Then use color codes like &7 and it will be colored then
What he's getting at, is that you shouldn't be tracking the crates in the CrateItem class. It complicates it
alright
The CrateItem class should only hold functions that relate to the actual crate. Tracking a master list of crates is out of the scope of that.
right
While it will technically work, it's not good coding practice
CrateItem is only going to represent a Crate and then everything else should be managed with a manager.
That won't solve your shuffle problem however. What's the issue with that?
Try avoid static in the CrateItem as it should not be needed
it seems that the id I tried to shuffle with was null
so it might be a problem with crate management funnily enough
Hmm, let me look over that code
right
The error happens in shuffle()?
K
when I tried to call the shuffle
there you are
is it ok to add the crate to the list of crates in the crate manager in the constuctor?
You should have an add method in the CrateManager
@naive goblet that method works for everything else in the string except for the players name
What r u trying to do
But if you have a stored list of crates somewhere, it would be ok to load those
Let me check this shuffle method first
ok, thanks 😄
sorry the id is so complicated
it makes it a pain to follow, whenever it's mentioned. I did have a warpper class for the contents (id.getRight())
It could be simpler.. that's what we're trying to help you with 😄
In shuffle, what is id? Is that the master list of crates?
no
the id is a crate id
essentially, in each crate id you have the ItemStack of the crate paired with a list of pairs
in each pair you have an ItemStack and a Weight
essentially, it's linking a Crate to it's contents
each item in the contents has a weight
What error do you get when listener tries to call shuffle?
null pointer exception
Of course
the classic
The data is null, and you are calling .isEmpty() on it
@naive goblet I'm trying to send a server message when someone uses a certain item, so it would say "{playername} has started an event" in chat, but the player name prints as white instead of gold like the rest of the message
where is this?
😮
ChatColor.translateAlternateColorCodes(‘&’, “&6” + player.getName() + “ &f text after”)
@cerulean snow
That will fail
how come?
You can't call a method (.isEmpty()) on a null object
small apart: you dont need to == true in that if statement
ah
Also, the || works from left to right
oh yeah I don't know where that slips form
The null check needs to be on the left
JC keep in mind that boolean should represent a success or a fail
ah ok thanks. I was using getDisplayName() not getName() lmao @naive goblet. works great now
if you do this, for example
boolean value = true;
if(value)
System.out.println("Value was true");
it works fine.
We can’t get the boolean of the Object if the object is null
👍
Also, || is a short circuit operator. Once it finds the first condition true, it quits checking the other ones
So when you do
if (x == null || x.isEmpty())
System.out.println("X was empty");
It does the null check, notices it was true, and doesn't check the second condition
Also, || is a short circuit operator. Once it finds the first condition true, it quits checking the other ones
@silent veldt inteeesting
that's fine though
because if it isn't empty, it's not null
That makes it safe, because if the first condition is null, it won't run the second check, which would cause an NPE
What is the cheapest way to check if any player is at a specific location?
Compare block x y z between 2 locs?
I am trying to regenerate a block, but I want to make sure no player is in the way. I assume that if I regenerate and a player is in the way, I will crush them.
huh, interesting
@silent veldt hi, to avoid having to add something everytime I add a new section for a new class, I was thinking about having a Set<? extends MyClass>
and then, given that each class requries the same parameter to be passed on the constructor, I could use reflection to create a new instance.
Is this a legitimate use of reflection?
I also thought about initializing the class iinstance with some default values and then if the configuration section was defined, I could just update it using a setter
I just tried running it again
this time WITH the null catcher
still got a null pointer
Let me see your new code
what would count as "player" as in like the person who clicked something in the console
NPE is often thrown when an undeclared field is used
I think I know why lmao
I remove the crate from somebodys hand
before I check with it
I think?
Let me see your new code
k
Is there a way to send all your players to a fallback server when your server shuts down (and how would you do it, code wise)
@boreal tiger You shouldn't need to use reflection if you are designing all the classes
You typically only need that when breaking into someone else's classes
Person person;
method() {
person.getName(); //Would throw NullPointerException
}```
right, would it better to just update with a setter then?
if that section is defined
!!!
I'm don't understand the problem 100%
Pog
lol
here's the problem @formal nimbus
How do I wait for certain amount of time?
BukkitTask
if (this.id == null) {
Should be
if (this.id.getRight() == null) {
it's not giving null anymore
what counts as "player" in the console
Ah, well that wasn't the null then. But it could have been null, so you still needed the check
I do both
Ah
Right
T
BukkitScheduler#runTaskLater(Plugin, () -> {
}, 20L); @cold wharf
@silent veldt some context
I have an abstract class Enemy which I then extend for different enemies.
Each enemy has some attributes I want to load from a configuration section.
I already fixed the null issue
20L == 1 second
Yup I see that. That works
👌 thanks again
Essentially I removed the crate from their inventory, before using that crate to check for the crate id
so essentailly the crate no longer existed
and I was passing in null
however
now i'm getting a different issue lmao
Guys, how can I make an excavation enchantment?
it's another null pointer excption!!!
wooooo
but at least the crate identification sysytem is working
@paper compass what did you come up with ?
this is progress
@Conclure#1262 can you give me an example pls?
And wym with excavation
Is there a way to send all your players to a fallback server when your server shuts down (and how would you do it, code wise)
rudra sure
Can either of you do voice? I think it would be much easier to explain that way
//onCommnad
Bukkit.getScheduler().runTaskLater(plugin, () -> {
sender.sendMessage(“One second has now passed”);
}, 20L);```
Craig how old are you?
38
Oww I am kind of like super young compared
Hey
Sup
Age doesn't define programming skill 😄
👍
lol I'm 16
I started programming when I was young. BASIC at least
cool 😮
BukkitScheduler#runTaskLater(Plugin, () -> {
}, 20L); @cold wharf
@naive goblet
Example pls
== you got pro skills
I wish. I still learn every day lol
//onCommnad
Bukkit.getScheduler().runTaskLater(plugin, () -> {
sender.sendMessage(“One second has now passed”);
}, 20L);```
@naive goblet
Rudra
This
I think programming is something you'll never completely figure out, no matter how old you get
Haha good one
OK I'm out for a bit. Good luck guys
Cya
Con Where do you put the X time?
Should I put a seperate BlockBreakEvent in each of my enchantment classes?
Oh
okay so like this
//onCommnad
double seconds = 3.0;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
sender.sendMessage(“One second has now passed”);
}, seconds * 20L);```
Oh will this work on events too?
And what if I leave it empty?
Leave what empty?
Like remove the send message
Yeah you can put whatever code you want there
//onCommnad
double seconds = 3.0;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//code that should be executed in x seconds
}, seconds * 20L);```
I am trying to do it so if you sleep after 5 seconds it will check of you're still sleeping or not and if you're still sleeping then it will change the time to day. I got everything working apart from the wait thing
is there a good way to Wget spigot plugins on a remote linux server
PlayerBedEnter
or curl
Should I put a seperate BlockBreakEvent in each of my enchantment classes?
//EventHandler
public void onSleep(BedEnterEvent event) {
Bukkit.getScheduler.runTaskLater(plugin, () -> {
if (event.getPlayer().isSleeping()) {
event.getPlayer().getWorld().setTime(3000L);
}
}, 100L);
}```
Idk if 3000 ticks is the right
1000
yeah change it to 1000 then
Aight tysm
Prison server
More specific
But my current block break event has like over 500 lines
@formal nimbus Send more code
k
and it lags the server
What is this code suppose to do?
it opens up a generic crate GUI
and the items asociated with the crate that was opened will scroll across the central row
@paper compass thats a bad code sry
mhm
it's only moving the items along once when I open a crate unfortunately
I'm looking for a way to optimize it
I tested the outer for loop by putting in a Bukkit.getServerSender.SendMessage in
and only got 1
when it sohuld be 100
*should
@paper compass maybe use a switch statement and enums to check enchants. Also use dependency injection instead of static instance of main.
rudra your main class
but how do I reduce lag
Oki
for(int i = 0; i < 100; i++)
CrateGUI.crateInventory.setItem(17, (this.randomItem(getContents())));
Bukkit.getConsoleSender().sendMessage("hi");
for(int itemIndex = 9; itemIndex < 17; itemIndex++) {
if (CrateGUI.crateInventory.getItem(itemIndex+1) != null) {
CrateGUI.crateInventory.setItem(itemIndex, CrateGUI.crateInventory.getItem(itemIndex+1));
}
}
``` @formal nimbus
add a {
OhSry it's not a question of how rather what does reduce lag.
Also what is that 100L?
100L is 5 seconds
working now 😄
each seconds takes 20 ticks
Oh oki
I'm just a dummy
JC nice
currently looking into servers that have managed to get mods working along side spigot plugins aswell. So far I've only seen mention of sponge which was a disappointing mess and how people say its not possible but nobody really gives any in depth detail as to why or how to make it possible. Currently my goal is to just get it working on 1.14.4 and then later when 1.16 comes out have the same done there aswell. 1.14.4 will be where I'm testing basically to get this working the first time.
Side question, why is minecraft weird and refering to plugins and mods as 2 seperate things when their both basically mods just one is serverside only?
Does sponge works with spigot plugins? The main reason is because the Forge API and Spigot API works totally different
Keep in mind that Forge API should allow devs to create new Entities and stuff which Spigot isnt capable of
iirc forge required some clientside handling while spigot was all server side. and no I'm 90% sure most spigot stuff doesn't work with sponge :p
yep
Well, yes
Client handles stuff like rendering and textures
ServerProxy handles items, behaviour etc
And in forge even in local worlds there is a "local server" running
Need to get out a couple of min bbl
Does anyone know he 1.14 equivalent to the 1.12.2 (World world)? I heard WorldServer is a possibility..?
Spigot API?
How do you use the placeholder API?
String format = "%player_name% >> %message%";
format = PlaceholderAPI.setPlaceholders(player, format);
?
iirc WorldServer is nms ?
Jeez checkout their documentation
Just use the World from spigot
\bukkit api
I am but it doesn’t works it’s ym super. It works fine in 1.12.2 but not 1.14.4
That worked con tysm