#help-development
1 messages · Page 2131 of 1
yea
i had a class for this but it went somewhere
i tried runnable.runTaskLater
dont
@civic dagger try right clicking the item and then waiting the cooldown
wait
1 sec
thats exactly what im doing bro
no
public class CooldownManager {
private final Map<UUID, Long> cooldowns = new HashMap<>();
public void add(UUID uuid) {
cooldowns.put(uuid, System.currentTimeMillis());
}
public long getCooldown(UUID uuid) {
return cooldowns.getOrDefault(uuid, 0L);
}
/**
* Call on JavaPlugin#onDisable
*/
public void clear() {
cooldowns.clear();
}
}
all you need really
well no
see this
if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 1000) {
event.getPlayer().sendMessage("cooldowncheck");
return;
}
coolDownsMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
smaller
also ignore the indent
?
private final CooldownManager cooldowns = new CooldownManager();
// somewhere
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
long cooldown = this.cooldowns.getCooldown(uuid);
if (cooldown > 0) {
player.sendMessage("cooldownmessage");
return;
}
// do code
this.cooldowns.add(uuid);
what i did is just same as this
ik
they use same mechanic and method
ik
so you know it dosent matter if i use your method or no because nothing changes right?
ik
its just better to turn this into an object so you can use it in other classes
yours is a code smell
one directive programmign
i forgot the name
yes BUT IF IT WORKS IN THE FIRST PLACE
try send the player coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L)
be grateful i fixed a code smell for you
ik how to use objects bro im programming in different langs for 3 years
the problem is
then use them
.
see whats happenin
its being modified somewhere earlier in your code
agreed
lmao ik whats about to happen
trying to fix something that nothing is wrong with it
this is funny
there obviously is something wrong with it
^
just do what i asked you to do
ok wait
and tell us what it says
not that code
this
.
no
if the difference between the current time and the cooldown time is less than 500 (meaning the 500 hasnt passed) then its still in cooldown
yeah no im right
ok then ill change it and see
he is right i think lmao
yeah lmao
is it?
gg
because time dosent go backwards
i told you it would be something miniscule you'd look over for hours
happens to the best of us
your welcoem
of course im not always right and even if i was i wouldnt wanna be a dick abt it
is im stuck at this for like 15 min
that 2 hours was stuck at a runnable
that runs itself
use my cooldown manager
for no reason
uh ill use that link later when my vpn get fixed
cuz i cant open it rn
it literally timeouts
@quaint mantle anyways thanks i would have never found that except if rewrited that code which was what i was thinking about
saved me hours lmao
i've probably made that error before so i knew what to look for
@quaint mantle
i just found a fact
a very good fact
you were both wrong and not at the same time
see this
time passed > 1000 -> false, your idea
timepassed < 1000 -> true, my idea, if time passed in ms is smaller than 1k then return
wow
lmao
?
your idea is if its false then dont do anything
mine is if its true then return
its same
yea lol
well just inverse the return
so
now
my problem isnt solved
because everything is same again
lmao running in a circle
.
wdym? bad english so example please?
inversează valoarea returnată
wow helped so much thanks bro!
if (timeElapsed < COOLDOWN_TIME) {
return;
}
// set cooldown
its literally what im doing
lol
if(System.currentTimeMillis() - coolDownsMap.getOrDefault(event.getPlayer().getUniqueId(), 0L) < 1000) {
event.getPlayer().sendMessage("cooldowncheck");
return;
}
but it dosent stop it
which leads to my 1 hour ago idea
ik deo
its false
no need to type
we’ve really spent 2+ hours here making a cooldown
and its not working
lol
alright idc anymore at this point let that mf player make tps 2
?
i gave up that means
because you didnt even read what i said
I reed your last line, I get kinda questionable.
Is there anyways to modify the vanilla loottables? like if i wanted to add a custom item to the loottables of abandon mineshaft chests?
wanna see something funi
now on how to actually do this loottable stuff, you're basically on your own
not completely i guess there is some threads for it out there
declaration: package: org.bukkit.event.world, class: LootGenerateEvent
Yeah ive seen all of that, on the LootGenerateEvent it gives me those datatypes but I can never get the loot table type
declaration: package: org.bukkit.loot, interface: LootTable
like the enum is never passed into the event
you gotta be able to set the LootTable somehow..
also if its possible to do with a datapack its 100% possible to do with a plugin
getInventoryHolder().getInventory().getType()
This returns an inventory type not a loottable enum
its not an enum..?
some type of LootTableInventory or smth?
he wants to know the loot table enum
there is no loot table neum
which is the "LootTables" enum.
declaration: package: org.bukkit.loot, enum: LootTables
Dude
It literally is an enum
you said LootTable
and i looked for loottable
and you give me loottables
we're programming yk gotta be specific
oh yeah my bad i forgot to add the S
didnt realize the words LootTable and LootTables look completely different
well when you say the LootTable enum im gonna look for a LootTable enum
Yeah sorry i should have been more specific, those two class names look completely different my b
i hope you try and sign up for a website and it doesnt give you a username because someone else has one that ends in 807 instead of 808 but its close enough yk
Yeah unlike you I can make inferences based on the context of conversations
.
yes because i can know you want to get the LootTables enum variant from this question
yeah so I have bad news, you can't get the LootTables enum.
make a map
Yeah thats what Ive seen
or a switch statement
a map contains key : value entries
and that would do what exactly
how would you get the keys do?
well
if you know the loot tables (like the instance of them)
map an inventory type to a loottables variant
that's what he is saying
you can know what is the type currently being generated, but even that is not accessible.
ok can we all just agree that these two classes should be accessible from within eachother
this is just bad api
fix it then
mr. discord helper
Yeah its not made in an intuitive way
spigot python edition
mapping NMS is an adventure sometimes..
Also this wouldnt work. Im looking for variants of chest loot tables, InventoryType returns the type of inventory. So it would only return CHEST but not the loottable of that chest
you could get the type of the block
nms through spigot is an adventure, dealing with nms without any mappings is the real adventure
inventoryholder, instanceof Chest
LootTable extends Key
which means you can check the key
and know what is the loot table
Keyed
big brain
and then we come back to making a switch statement
or you could be ballsy and use LootTables.valueOf
This still does literally nothing for me. I dont need to know if its a chest or not. I already know how to determine that. I need to get the loottableS from the chest when its generated
i told you that you could get the variant of chest from this
Im looking for variants of chest loot tables
why would you make a switch statement tho? wouldn't you just, check if the key == "chest/abandonned_mineshaft" (this is absolutely wrong in terms of language, I understand it, it's just for demonstration purposes)
thats all he wanted
Im gonna try this rn and see if the loottable object you can get from GenerateLookEvent #getKey has the loottable key
can anyone help me make a scoreboard that I can make a score change INSIDE the scoreboard? so like not the actual score but like the text of the scoreboard goes from "team 1: 0" to "team 1: 1"
then why make switch statemet?
oh i forgot because we were scrambling on about LootTable was similar to the name LootTables
do you mean the red numbers?
it does
Oh then there we go
No
😂 Unlucky
the text of the board would change
well hm
https://www.youtube.com/watch?v=7QXokn_GEGg slightly outdated but explains it well
Keeping score??? Learn how to create scoreboards in 1.15 Spigot! Great for minigames and hub plugins :D
Patreon:
https://www.patreon.com/codedred
Donate to me :)
https://www.paypal.me/CGMax
Join my discord:
https://discord.gg/zMzXSgk
Follow the Twitch Streams:
https://www.twitch.tv/coded_red
------ Links ------
Download Eclipse: https://w...
huh okey
while you do that
I do nothing
I was gonna ask for help in a thing, but might as well not, gonna make chat confusion
build a new scoreboard?
Dawg just ask ur question
"Wanna hear something?" "Oh nevermind"
this is what the entire scoreboard looks like if it makes it less confusing
Then dont edge people with ur "I have a question but i dont wanna ask"
ironic how not asking the question caused more chat confusion
really..
fun fact a scoreboard issue is like the least confusing thing lmao
we deal with a lot worse stuff
how did you set it in the first place?
a command
probably would just reuse that but with a different number
oh
what
are you using another plugin or something
wait you cant edit a scoreboard? you have to rebuild it?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I am using another plugin butI can manipulate that code if it
save a hashmap of the team # and its score, then when u wanna update it just put whatever it is +1
im pretty sure coded red doesnt do that
ah ok!
fun fact: youtubers arent always right
most of those spigot tutorials are pretty shitty
He does but he generally gets the point across. Like he uses catch (Exception e) alot which makes people mad
yea
im just gonna ffucking pay someone to do it idek why I try
tbh I catch exception when theres like 3+ of em lol
I do
I use it for other things aswell
just dont have the stamina rn
the webpage
I usually only do Exception if I dont know what kind of exception id be catching and dont feel like finding out
any suggestions on how to 'cancel' certain blocks from slowing down players (soul sand, cobwebs, honey)
the thing I did that I was most proud of myself for doing was making a command that tells you when someone shot or got shot by a bow lmfao
best guess would be to give them speed or remove the block client side as the speed change is client side
does that effect cobwebs
it doesn't, it doesn't change fov or anything, doesn't even appear in the UI
yea
What is the listener for a arrow touching a block?
only problem is theres a limit
yeah but its high af lol
ty very much 🙂
yeah so basically, I have this current setup.
basically I want to make it so I can know if a hopper is pointed towards a machine block
any ideas?
without making the server go brr mode.
(dropping tps crazy)
armor stands probably best idea yeah
you can get the hopper block, it implements a Directional object, use that for the method getFacing
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/material/Directional.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/material/Directional.html#getFacing()
yeah but when do I check it?
did you even open the link?
it's not like the hoppers are fast fast af
and can transfer items every tick
what?
what
okey so I'll reform that
you are asking something outside the scope of your original question
you asked originally how to get what direction a hopper is facing, which I answered above
you can pick how frequently you check that
doubt doing as check like that wont be that bad either
or you could just set it to a variable and then reference that every time you want the hopper to function
really honest here, I really don't think I have any choice, but I don't want to check if the machine has a hopper around it..
idk, It just doesn't feel right..
what does the green underline in eclipse mean?
hover over it
if(event.getHitBlock().equals(Material.BARRIER)) {
``` dis shit wrong?
eclipse 🤢
that will never be true
unlikly that it would work
... ok
enums are compared with ==
not with equals
that too ^
how do I compare then?
just
cause Material. is the only thing that I can think of
LootTables.valueOf(event.getLootTable().getKey().getKey().split("/")[event.getLootTable().getKey().getKey().split("/").length-1].toUpperCase())
This gets the loot table enum when u open a chest that hasnt been looted yet
damnit
yeah that's the enum!
I changed it
if(event.getHitBlock().getType() == Material.BARRIER) {
yeah that is correct
lfg
ima test it
you gotta be fucking with me
the guy who owns the server I test with shut it down
I am...
.equals is for like strings right?
and objects*
no its for all objects
== is for enums.
Ik == was like roblox coding too and shit
== is used for primitives and enums
my 3 year old spigot server I havent loaded up and is still running 1.8
.equals() checks the information of the objects
== checks if the objects are the same
I run 1.8 spigot
if they are the EXACT same object
(new String("hi") == new String("hi")) returns false
like same point in memory
ah ok
ye.
== checks if they have the same pointer
yall i get it they are different
Not always, Strings are in a bucket so their instance could be the same
now can we talk about the econimical and political state of the world rn?
fr
but you're calling new????
anytime you use the NEW keyword it creates a new spot in memory. So comparing NEW anything with an object other than itself will return false
yes, but if a string of the same contents exists in teh cachee it's instance will be used
not if the new keyword is used
I'd have to check that
lets go it works!
amongus
I will check it rn
k
real talk. Dasani or Fiji
deez nuts
"yeah I format my code correctly and dont call every class I have main" - 🤓
good to know
basically, dont use == if youre not comparing enums or primitives
well you could use == if the object is a singleton 😂
whats a singleton
Dunno 😂
it's an object that is instantiated only once.
it is actually sometimes better to use == over .equals for enums. Like if you hook into the PlayerInteractEvent and want to check if a block is gravel, using .equals will give u Null exception if the player interacts the air. if you use == it will not generate an exception
good point.
that makes sense
so you dont need to do the block==null check
actually it is better
the class that extends javaplugin is a singleton
ur main class
enums are constants, always use == for constants if that's what you're checking
all my classes are main
nice
nice
nice
I am yet to make any plugin using more than 1 class
jesus
that isnt a tutorial;
Yes it is always better, can still use .equals but == will never generate an exception. Good point
my god (not to u)
(who is u)
(u)
lmfao
lmao
what are we doing ..
lol
confusion spikes
what are you not doing
sleeping
lmfao
my vulture will shit on your little cobra
i started yesterday
oh ok
This is fine for smaller projects but for larger ones you really should look into how to deal with multiple classes
"1v1 me in spigot development" - :sigma:
we should do clash of code
if apis are allowed, I win
😂
lmfao
just use TNAHRSC
just get an api that literally builds u an entire plugin with 1 method
this is my api.
if I make a plugin that requires multiple listeners or makes me send a variable over to a different class I just make separate plugins, that makes it easier to manipulate but herder to orginize
why do i need an account
so silly
so goofy ahh]
im sorry but this is too far 💀
SpigotPluginAPI.make("MyPlugin").load(this.getClassLoader()).module(WeirdCommands.class)
Learn how to use static variables (people who call using static variables "static abuse" are nerds)
how
sorry mate my api already did what u can do in 2 days
can i spectate? lmao
or he should just learn to use objects
fr
tell mee how to use static variables
pls
public static int number = 0
like whats the problem with me preferring static singleton over dependency injection
put static before ur datatype declaration or before final
im not a fucking inverter
its not working guys
oh nevermind this is ez
we have to remember that we are quite literally coding a rock that we shaped and put lightning into
i am totally going to win the clash of code
there is no right way to do things
cmon someone stream that clash of code for me xD
...
what is a datatype, declaration or final?
lets you do <Your Class Name>.<Static variable>
datatype is like "int"
ahh ok
basically
ahh ok
?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.
static makes it belong to the class name instead of instance
asks a question
Youre asking questions that are basic to java as a language, youll learn more from learning java than asking people to teach you java
I have went to all of those sites and found nothing that I didnt already know
well static variables... are easy..
so i must be either super smart or super stupid
@compact haven bad
s = input()
v = []
skip = False
for c in s[::-1]:
if skip:
skip = False
else:
v.append(c)
skip = True
print(''.join(v))
ew python
Interesting
ur bad
huh, photoshop
PHOTOSHOP
Wait actually it doesnt reference static variables
public override event static final synchronized void
combined a couple languages there
jojo refrence
hot
bruh wtf is synchronized and arbitary they didnt teach me these stuff :(
for (i in 0..5)
bro I asked someone to make a plugin for me and I was gonna pay them and it was so easy they did it for free 💀
variable conventions
protected private final async boolean Object<Class<T extends Object> extends Object> int { }
Thats usually how it goes
am I not meant to print it out
@knotty gale https://www.youtube.com/watch?v=xk4_1vDrzzo&t=0s Pretty good video for people learning java. Good explanations of stuff. Timestamps for concepts
Java tutorial for beginners full course
#Java #tutorial #beginners
⭐️Time Stamps⭐️
#1 (00:00:00) Java tutorial for beginners ☕
#2 (00:20:26) variables ❌
#3 (00:32:58) swap two variables 💱
#4 (00:36:42) user input ⌨️
#5 (00:44:40) expressions 🧮
#6 (00:49:13) GUI intro 🚩
#7 (00:55:01) Math class 📐
#8 (01:01:08) ra...
i win
k thx
03:40:27 static vars
who wants a python 1v1? i can just ask a question that you cant even find in stack overflow xd
looks at vid "Oh cool!" 12:00:00 "..."
Ah ur right, u should be able to learn an entire language in an hour
codingwithmosh >>>
i mean i thought it would be like a fucking series
ok i figured it out
it is
bro code just mixed them inside a single video
Well if ive ever not understood a concept, i usually looked to this video
k
@quaint mantle ur just sad that i beat u so quickly
huh
lets be honest that 7 mins was like too long for u to take
protected static async final void Object<T<Object extends BukkitObjectOutputStream> extends Object<Object extends Object<Object extends Object>> getYourMum() {}
@quaint mantle Idk if u saw but I found out how to get the loot table enum from the LootGenerateEvent, I can send u the code if ur interested
extends object
idc
ok
im fucking with you
extends object
i have forgotten every piece of python i have ever known
ima be real with yall
I only really need listeners for the rest of what I am doing
like it is just hitlogs arrow logs and shot logs
why does this not work
wtf is this voting website add bullshit
Can a dropped item be cast to living entity? I’m guessing probs but
this is rigged
How can I affect a dropped item with a potion effect then?
You can add glow effects using Teams
we should go again kekw
Is that the same thing? I thought it was smth dif
should be the same
Mk I’ll try
How to make an entity glow with certain colours (rainbow)
How can i make bukkit runnable inside a function?
Just use the Bukkit class
?
new BukkitRunnable
Or you can use an anonymous class
but why
else{
player.sendMessage(ChatColor.LIGHT_PURPLE+"You frozed: "+target.getDisplayName());
target.sendMessage(ChatColor.RED+ "You got frozen by: "+player.getDisplayName());
Utils.createCircle(player,player.getEyeLocation(),1.5f,Particle.REDSTONE,Color.fromRGB(6,210,6),Sound.ENTITY_ILLUSIONER_CAST_SPELL,-2,1.25f);
frozenPlayers.add(target);
new BukkitRunnable(){
@Override
public void run() {
frozenPlayers.remove(target);
}
}.runTaskLater(this.plugin,20*10);
}```It throws error
the error being?
you have to implement methods
it creates a new run function at the end
https://pastebin.com/6TTrBZD2
Thats the whole class
is it because i have to do somethiung ion main class also?
i cant build my project
well of course you cant
your project's groupID and artifactID are the same as net.tnemc.TNE
that's meant to be the identifier for your project, not the dependency
i cant find it
Do you currently own a domain?
no why
do you plan on owning a domain
no
okay then I guess just use like me.limpeex for the group ID and rpplugin for the artifact ID
then move all of your packages in the source to me.limpeex.rpplugin
remove your Main class from the Main package, rename all packages to lowercase
yeah
delete the Main package, name the Main class RPPlugin
he's in intellij
its like folders
im trying to get TNE as dependency
very aware
your maven pom.xml needs to have your own groupID and artifactID
not just the dependencies
you know how bukkit stuff is like
as for every other change I've suggested, it's to make your project follow conventions
org.bukkit.player
or whatever
their groupid would be org.bukkit
and then artifact would be Bukkit
artifact ID meant to be lowercase, and it wouldnt be that
How are you getting an instance of your main class, because it looks like you're not doing it properly
in any case, your code is meant to all be under a package <reverse domain>.<project name>, then the group id is your reverse domain and the artifact id is the project name
LuckPerms for example (and about every other Java project) uses this convention, me.lucko (Luck owns lucko.me) and (luckperms), hence the group ID me.lucko and the artifact ID luckperms
along with all the source code being under me/lucko/luckperms or, in Java, me.lucko.luckperms
if you only care about fixing the one dependency problem, and not the other ones present in your code, just change the group id and artifact id to what I said previously
then you'll be able to build a problematic plugin
bro don't listen to these loser haters, put your main class in main.main.main.Main so people know you're the real MVP
this is a joke btw^^
then also name every other class Main1, Main2, Main2... and name every method main1, main2, main3
every field should be called main, every interface should be called main, every config file should be called main
I recommend hacking spigot so you can even generate a main.yml file instead of a plugin.yml file
is the dependency already installe in your m2
or is it using something like jitpack
if your using a dependency like this too make sure you shade it if it won't be in the plugins folder
you can use maven-shade plugin for this
wdym
maven dependencys are located in your .m2 file
on linux it'd be /home/usr/.m2
if you didn't properly install your dependency look it up
maven provides tools to do this
again if your using something like jitpack or repsy follow their doccumentation as its pretty well descriptive of what you need to do to depend off your custom dependency
im not using that
Also in your future dependencies make sure you use lowercase artifact ids per mavens conventions
i dont even know what the heck is that 🙃
I reccomend doing self-research its a good trait to learn and get used to
maven is pretty well doccumented and explained on apache given your needs
use google correctly by being descriptive yet general simultaniously
descriptive of your issue more general in terminology
how to get blocks around block
block faces is probably the best way
Block#getBlockFace(BlockFace face)#getBlock
declaration: package: org.bukkit.block, interface: Block
@kindred valley you've changed the wrong thing
the thing you changed is the ID of the dependency itself, not your own project's ID
the error is that the ID is the same, which it shouldnt be
the project isn't TNE, the project depends on TNE
that doesn't work
not that does not find TNE
you need to actually put the TNE repo in
repository
because it doesn't know where to get the dependency from
the TNE website should give you the repository
are you meant to be depending on such an old version
blockface something
TNE is in Maven Central, but this is the latest version -- 1.1.8.26 https://mvnrepository.com/artifact/net.tnemc/TNE/1.1.8.26
quite the difference from a development version that you're trying to use
are we allowed to text it to here
be easier if you looked at em yourself 
yes
I don't really know where the fuck it is lmfao
does TNE not have a guide for this?
https://github.com/TheNewEconomy/TNE-Bukkit/wiki/Compiling#prerequisites i just found this
sorry
i dont know if you can use github repos for that
thats not what that section is for
that's specifically for compiling the TNE project itself
not for dependening on it
what version of TNE are you using
1.1.17
their entire website is just error 404
ugh this is so confusing
you can always just import the jar as a file
instead of repo
i dont think they actually have a public maven repo
they use github packages
had to go through an old Issue to figure that out
why is that so difficult for them to put in the README
looks like theyve stopped supporting it
change the dependency section to that info
<dependency>
<groupId>net.tnemc.TNE</groupId>
<artifactId>tne</artifactId>
<version>1.1.9.2</version>
</dependency>
thats from the end of 2019 💀
this is stupid
yeah it would seem they just don't publish artifacts anymore
but try the one above
I can't really tell what versioning scheme they are using, but it might work unless they've made breaking changes
I actually dm the creater
I want to use the vault but vault does not have much functionalities
just try the one I posted above, see if it works
if not then yeah wait for his response
its not working yes
how can i manupilate the block position
Block positions are fixed
but i have seen many plugins changing it using items when clicked
u wanna move a block?
yah
each location contains a block type. You can set those types per location. If you want to animate moving a Block you use Entities
you gotta set the type of the block you click to air
and then get the location of the new block
and set the type to the first block's type
ooo
yeah because you can't set a block's position
as elgar said its fixed
theres a set block for every position in the world
thanks for the idea 🙂
no problem
Falling blocks?
Location#getBlock()
ok
Location#loctoBlock?
there isn't a Location#getBlock()??
yah
Player player = event.getPlayer();
if(player.getInventory().getItemInMainHand().getType()==Material.GOLD_INGOT){
Block block = player.getTargetBlock(null,4);
double BlockX = block.getX();
double BlockY = block.getY();
double BlockZ = block.getX();
player.sendMessage(ChatColor.RED+"X:"+BlockX+",Y:"+BlockY+",Z:"+BlockZ);
BlockData blockData = block.getBlockData();
block.setType(Material.AIR);
Location BlockX1 = new Location(player.getWorld(),BlockX+1,BlockY,BlockZ);
Block block1 = BlockX1.getBlock();
block1.setType(Material.OBSIDIAN);
player.sendMessage("Done");
```Sorry to disturb again but the blocks diappears and the new block does not spawns
What is the best way to save a list in a mysql-table?
How are there systems that auto login premium user?
like i thought they cant communicate with mojang server cuz of onlinemode off
is there any way to make an arrow not hurt entities but just fly through them?
Probably by giving them piercing, see the video of BlueCommander. He done that in vanilla but I think the process is pretty much the same
my plugin does not creating data folder why can it be
you haven't called `saveDefaultConfig()
i had
then you don't have a config.yml in your jar
?paste
i have
one fo the two is fact
can I convert spigot's Color class to ChatColor
ah great, thanks
pls elaborate
I have this event that doesn't work. am I supposed to compare the things that I put in the if statements differently?
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
if (event.getClickedInventory() == null || event.getCurrentItem() == null) { return; }
else if (inv.compare(event.getClickedInventory())){
Player player = (Player) event.getWhoClicked();
if (event.getCurrentItem().getItemMeta() == ItemManager.fireWand.getItemMeta()){
player.getInventory().addItem(ItemManager.fireWand);
player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
player.closeInventory();
} else if (event.getCurrentItem().getItemMeta() == ItemManager.dragonWand.getItemMeta()){
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
player.closeInventory();
} else if (event.getCurrentItem().getItemMeta() == ItemManager.lightningWand.getItemMeta()){
player.getInventory().addItem(ItemManager.lightningWand);
player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
player.closeInventory();
}
event.setCancelled(true);
}
}```
inv.compare is a function in the class
like can I not compare item meta like this? item.getMeta() == item2.getMeta()
how can i call plugin.getConfig() outside of the main class
now its like this if (event.getCurrentItem().getItemMeta().toString().equals(ItemManager.lightningWand.getItemMeta().toString()))
and it still doesnt work
Use your main class instance
public static Main instance;
public void onEnable() {
instance = this;
}
Main.instance.getConfig()
U should learn Java tbh
I don't understand how do I compare ItemStacks
Why are you converting them to strinf
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.
^^
because just putting == or .equals() doesn't work
how do i fix
im trying to check if an item in equal to another item
By learning java
Then just do a instance check?
it is an instance
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
if (event.getClickedInventory() == null || event.getCurrentItem() == null) { return; }
else if (inv.compare(event.getClickedInventory())){
Player player = (Player) event.getWhoClicked();
if (event.getCurrentItem().getItemMeta().toString().equals(ItemManager.fireWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.fireWand);
player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
player.closeInventory();
} else if (event.getCurrentItem().getItemMeta().toString().equals(ItemManager.dragonWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
player.closeInventory();
} else if (event.getCurrentItem().getItemMeta().toString().equals(ItemManager.lightningWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.lightningWand);
player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
player.closeInventory();
}
event.setCancelled(true);
}
}```
jesus
what is this code
im comparin the instance of Wands to an ItemStack
Make variables please
the event
i m saying its very bad
y
Use variables whenn u call thiings multiple times
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
Inventory clicked = event.getClickedInventory();
ItemStack current = event.getCurrentItem();
if (clicked == null || current == null) { return; }
else if (inv.compare(clicked)){
Player player = (Player) event.getWhoClicked();
if (current.getItemMeta().toString().equals(ItemManager.fireWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.fireWand);
player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
player.closeInventory();
} else if (current.getItemMeta().toString().equals(ItemManager.dragonWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
player.closeInventory();
} else if (current.getItemMeta().toString().equals(ItemManager.lightningWand.getItemMeta().toString())){
player.getInventory().addItem(ItemManager.lightningWand);
player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
player.closeInventory();
}
event.setCancelled(true);
}
}```
here
what is "TOSTING"
I have a direction in vector variable , how can i use it to tell if the player is looking at (x or z)
which takes a generic which extends GameMap
toString
get the player looking at vector
In the gameMap class I'd like to be able to call the addMap() function
if I shouldn't convert these to string so how do I compare them?
how do i compare itemStacks?
now I can only do this if the GameMap constructor instead takes a GameType which starts with itself
like if (item instanceof item2)?
Vector direction = player.getEyeLocation().getDirection();
I did that but i want to summon mobs in front of a player so i can i use thats vector
like GameType<this, ?>
bit obviously that's incorrect syntax
is it even possible to do?
Vector blockInFront = player.getLocation().getDirection().normalize();
can I ask what the normalize does
what...
makes the magnitude 1
you use this for direction vectors
they want to compare items right
to check if item is some item
instanceof is classes
if (item instanceof ItemStack)
i see thanks
not if (item instanceof item2)
but how can i use it as a location to summon mobs in fron of players eye?
so how do i compare 2 itemStacks?
item1.equals(item2)
cause it is not instanceof
i've already tried that
get the location from that vector and spawn at that llocation using World#spawnEntity
yes and...?
ok
anyone?
I changed it to item.equals(item2) like you said and nothing happens
what are you trying to compare about the items
just if they are the same type
or do you want meta as well
enchantments, etc
wait can I compare inventories like this?
for (int i = 0; i < this.getInventory().getContents().length; i++){
if (this.getInventory().getItem(i) != inv.getItem(i)){
return false;
}
}
return true;
}```
check if its the exact same item
so compare meta?
.equals should be working
if (!(this.getInventory().getItem(i).equals(inv.getItem(i)))) like this?
ItemStack#isSimilar()
looks like that doesn't compare amounts tho
public boolean isSimilar(ItemStack first,ItemStack second){
boolean similar = false;
if(first == null || second == null){
return similar;
}
boolean sameTypeId = (first.getTypeId() == second.getTypeId());
boolean sameDurability = (first.getDurability() == second.getDurability());
boolean sameAmount = (first.getAmount() == second.getAmount());
boolean sameHasItemMeta = (first.hasItemMeta() == second.hasItemMeta());
boolean sameEnchantments = (first.getEnchantments().equals(second.getEnchantments()));
boolean sameItemMeta = true;
if(sameHasItemMeta) {
sameItemMeta = Bukkit.getItemFactory().equals(first.getItemMeta(), second.getItemMeta());
}
if(sameTypeId && sameDurability && sameAmount && sameHasItemMeta && sameEnchantments && sameItemMeta){
similar = true;
}
return similar;
}
found this modified version of the original method you can use if you want
wouldn't it cause errors if this item has no durability?
like a stick
or a slime ball
ok
it worked 🙂 one last thing it spawns at the right front can i change the disance
normalized sets it to 1
try see if theres a setMagnitude or setDistance method on it
i dont use vectors often
it says Cannot resolve method 'getTypeId' in 'ItemStack'
ok
getType
change it
k
to that
I cant find 😦
how do I add dependencies into my plugin.yml ?
yeah but is the line where i'm putting it mattering ?
okay
public void OnClick(InventoryClickEvent event){
Wands inv = new Wands();
Inventory clicked = event.getClickedInventory();
ItemStack current = event.getCurrentItem();
if (clicked == null || current == null) { return; }
if (inv.compare(clicked)){
Player player = (Player) event.getWhoClicked();
if (inv.isSimilar(current, ItemManager.fireWand)){
player.getInventory().addItem(ItemManager.fireWand);
player.sendMessage(ChatColor.GOLD + "You now posses the power of fire!");
player.closeInventory();
} else if (inv.isSimilar(current, ItemManager.dragonWand)){
player.getInventory().addItem(ItemManager.dragonWand);
player.sendMessage(ChatColor.LIGHT_PURPLE + "You now posses the power of the dragon!");
player.closeInventory();
} else if (inv.isSimilar(current, ItemManager.lightningWand)){
player.getInventory().addItem(ItemManager.lightningWand);
player.sendMessage(ChatColor.YELLOW + "You now posses the power of lightning!");
player.closeInventory();
}
event.setCancelled(true);
}
}``` @earnest forum still nothing happens which means that none of these if stetements are true
thats weird
try print the bools inside of the isSimilar method
only for one of them so just comment out the rest of the ifs so you dont get spammed
k
How Can I Fill My GUI with black glass
loop through all of the slots and set them to glass
thanks
How are there systems that auto login premium user?
like i thought they cant communicate with mojang server cuz of onlinemode off
how to increase magnitude of vector?
Bro i found it , vector#length
sorry length is use to get the lengh not to change it we need to use multiply or divide
multiple works 🙂
thanks for helping earlier
np
my yamlconfiguration used to be like kitname: items: ...
and i looped all of the kits like this for (String kit : KitData.get().getKeys(false)) {
but not i changed the configuration like this Kits: kitname: items: ...
how do i loop all kitnames in this configuration?
i tried that
how to customize a entity that i want to spawn
