#help-development
1 messages · Page 1663 of 1
it's been 8 years since i touched java, i forgot everything
i dont get this line at all, but i guess i dont need to
Well, its the same as before
however you are just passing this thru the constructor
which refers to the current class
The constructor MyEvents(App) is undefinedJava(134217858)
com.thechemicalworkshop.MyEvents```
import?
did you copy the code i did
nope, his
You should also make sure that the right App is imported too actually.
unless you need instance fields there is no need Dessie
im confused aswell.. should have used git.. whoopys
If he's importing a completely different App class, that doesn't extend JavaPlugin, it would whine about it
Undo that (for real)
package com.thechemicalworkshop;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;
public class MyEvents implements Listener {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
// System.out.println(player.getName());
int delay = 1;
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(
ChatColor.RED + "" + ChatColor.BOLD + "" + "aghh you died !\n" +
ChatColor.RED + "" + ChatColor.BOLD + "" + "you can spectate others or use " +
ChatColor.GREEN + "" + ChatColor.BOLD + "" + "/lobby " + ChatColor.RED + "" +
ChatColor.BOLD + "" + "to go back");
player.spigot().respawn();
// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
}, delay);
}
}
myevent.java
^ You need the constructor
top or bottom?
And then you should be Set to Go hipefull
but is a good practice
Convention is constructor in top, but doesnt matter
convention is to write whole class in 1 line
(after the class ClasName { )
Tjough
okay lemme try to compile..
[23:45:09 ERROR]: Error occurred while enabling BlankPlugin v0.1 (Is it up to date?)
java.lang.Error: Unresolved compilation problem:
The constructor MyEvents(App) is undefined
at com.thechemicalworkshop.App.onEnable(App.java:9) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.17.1.jar:git-Paper-85]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-85]
i bet i messed smth up, again
i think i'll do everything in 1 file
why?
its leads to horrible unmaintainable code
well i'm done if i get this working
Because it's better If you learn from mistakes
?paste your events and main class
for now i need like 5 basic pkugins
trojan
oh well just use pastebin ig
i did few hours of java dev for android like a year ago
and i did learn java like 8 years ago...
package com.thechemicalworkshop;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.entity.HumanEntity;
import org.bukkit.GameMode;
import org.bukkit.Bukkit;
public class MyEvents implements Listener {
private JavaPlugin plugin;
public MyEvents(JavaPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
Player player = e.getEntity();
// System.out.println(player.getName());
int delay = 1;
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "" + "aghh you died !\n" + ChatColor.RED + ""
+ ChatColor.BOLD + "" + "you can spectate others or use " + ChatColor.GREEN + "" + ChatColor.BOLD
+ "" + "/lobby " + ChatColor.RED + "" + ChatColor.BOLD + "" + "to go back");
player.spigot().respawn();
// Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say hi");
}, delay);
}
}
compiling
i wish the compiler would tell me
Anyone know
My friend can't get unbanned
I'm on the proxy
And i unban him
He won't get unbanned
you've already asked in #help-server
Ooops
[23:50:51 ERROR]: Error occurred while enabling BlankPlugin v0.1 (Is it up to date?)
java.lang.Error: Unresolved compilation problem:
The constructor MyEvents(JavaPlugin) refers to the missing type JavaPlugin
at com.thechemicalworkshop.App.onEnable(App.java:9) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.17.1.jar:git-Paper-85]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-85]
i feel like 1 file...
i thought it's all easy modular
are you not using an IDE
well my "IDE" gives me tons of errors..
mayb eyou should resolve them then
even on code you guys gave me, there are errors on imports
do you even have the jdk
The import org.bukkit cannot be resolvedJava(268435846)
import org.bukkit.event.Listener;
yeah
then you don't have bukkit as a dependency
io have spigot
so can i just replace all functions wiith spigot? since im using spigot anyways
also spigot docs
you do not have spigot added as a dependency which is why your IDE is screaming at you
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>LATEST</version><!--change this value depending on the version or use LATEST-->
<type>jar</type>
<scope>provided</scope>
</dependency>```
make sure you have the repository added, try specifying a version, make sure your IDE is actually using maven
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>```
plugin.yml
Incorrect type. Expected "string". for version...
even tho it works fine ,and the tutorial on spigot says to use this
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-vs-code/
i was following this
vscode is very ehhhhhhh when it comes to java
well im not gonna switch for 2 reasons
using vscode for too long
dont have space
well, if i switch to another IDE, my efficiency will go way down
plus, setting up vscode is easy, eclipse is massive pain
well, years ago it was at least
For the first few days. Then it goes up.
how big?
What do you mean how big? Do you only have 64 gigs of disk space?
like less than a gig
um... also i have multiple machines
65 to be exact
I got weird problem with yml file
## Drop chances per block!
## Chance: Can be set from 0.01 to max 100 (100% or above will give sure drop).
## NumTokens: Number of Tokens given to the player upon mining a block.
## Per World chances will override Global chances!
## Material types 1.8 https://helpch.at/docs/1.8/org/bukkit/Material.html
## Material types Spigot lastest https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
Options:
#Token Drop messages
Message:
Enabled: true
##Type: CHAT, ACTIONBAR, TITLE, SUBTITLE
Type: ACTIONBAR
##Timed message to display how many tokens player earned in last (60) sec
TimedMessage:
Enabled: false
##Type: CHAT, ACTIONBAR, TITLE, SUBTITLE
Type: CHAT
##Delay is in seconds
Delay: 60
## Drop tokens to the floor as withdraw item
FloorDrop:
Enabled: false
## This will be signature on item
Signature: "&7Block Drop"
##Disable drop is specific world for Global Drops
NoDropWorlds:
- world_the_end
DropChances:
Global:
IRON_ORE:
Chance: 100
NumTokens: 1
CustomName: "&bIron Ore"
Worlds:
world:
COAL_ORE:
Chance: 50
NumTokens: 3
GOLD_ORE:
Chance: 60
NumTokens: 5
world_nether:
IRON_ORE:
Chance: 40
NumTokens: 80
DIAMOND_ORE:
Chance: 0.5
NumTokens: 15
##Config version (PLEASE DO NOT EDIT)
ConfigVersion: 1.1```
?paste
Only one space before TimedMessage
Needs 2
ur good
still not working
lierally enough space
@hasty prawn
yeah, problem is i have multiple machines...
Does it say FloorDrop now instead
and i really wanna keep the bare minimum
I literally just googled yaml parser, took the first link and threw your stuff in there.
Your Indentation is broken
Most the indentation is broken
okay thanks for help, also rip, gotta go sleep
You can get a brand new 120Gb SSD for 16 bucks.
i bought one for 20€ yesterday? or 2 days ago
last slot filled
F
how many slots do you have for such a small amount of disk space
also, for my other machine, oracle storage expensive asf
6
oh
the on i'm on is a vm
did you put 10gb ssds in each one or something
no i have 120gb ssd for coding, which is 65 alocated rest for backups
Lol ive just found a 1TB hard drive for 28 bucks. Storage is cheap nowadays...
as for oracle sotrage im limited to 50gb disk 🙄
i tried harddrive, massive pain
mechanical is
you have a very strange setup
yupp, but i dont want to get malware, that's why i use isolation
i have never been concerned about malware
yes, i use ghidra 😂
Windoiws defender is all I have
^
what are you installing which you need to be so paranoid over
same
malware?
from what? intellij?
ghidra
no, whatever i find on itermet
to decompile ig
everybody knows jetbrains are secretly infecting all out machines
then decompile with ghidra
what sketchy shit are you finding then
java 😳
usually cheching how it works, trying to understand etc
sometimtes it yeets the VM
@lost matrix 's join message plugin
Browsers are safe nowadays. If you dont go to www.flank-my-pc.net download the first catimages.png.exe and execute it you wont be in danger too much.
also i use VM's for privacy... when running long streams like 12+h i porefer not to show my stuff to everyone
problem is, that is my goal
why
to download that skethy stuff, see if i can obfuscate it, figure out how it works
ad block and DuckDuckGo privacy is all you need in a browser these days
Dont know what you mean. Ive never written one.
you are just causing yourself problems here really to the point where you can't even install IntelliJ
im not gonna switch and learn ide after years of dev on vscode
then you are going to have years of issues using vscode
Wtf. People actually use that...
what was file size
possbily, then i try to catch the basics to save few bucks
2MB
xDDDDD
also VPS ssd space so expensive... jeez
anyways, thanks for help, i'll leave it either tomorrow or whenever, or i can remove the scheduler and respawn line... it will be a bug
like it tells you you died, do X to leave and then say you dies due to smth
duck duck go... wow thats something i havent used in a while
Thats my default browser
google chrome with google does me fine
more conserned about memory/cpu
whenever I used duckduckgo I would always end up using the !g bang to get google results instead
I also tried introducing the term duckduckgoing instead of googling but half the people never heard of that.
lmao
the ddg results were never as good as google's no matter how much i wanted to use it
"lemme just duckduckgo it"
also a question, should i go into trouble of combining 2 simple plugins into 1?
let's say plugin A does spectator aafter death
and plugin B does custom join message
how much performance takes the loading plugin stuff use,. like the code that is in every plugin anyways?
like i need 6 plugins, and i could either add them to servers or allways add 1 plugin but percompile them toegther?
some servers need 1 plugin some need all 6
i hope you get my question
Did you make these plugins?
is it worhth compiling like 20 pluging instead of 6?
The performance difference is negligible
Still small
oh
why easier?
And also easier to handle in terms of development
Because you don’t have to back and forth
I personally write one big plugin for my servers. Sometimes i use modules, sometimes packages are enough.
It can even help with performance a bit if you dont have to check if a damaged entitiy is a player in 10 different listener methods.
And it’s annoying
well the problem would be
if i chance one plugin
i need to change all 20...
let's say i have
op on join
spectator on death
which equals
1 op on join
2 spectator on death
3 op on join and spectator on death
The only problem is version control. Because you team needs to understand how to work on a monolith
monolith? i use git, and my team is lazy, i only have one java dev, not even mc dev, just plain java he sometimes helps
also git is private
so how i give him access is a zip
You can still have private gits?
And also don’t use Zip to distribute files around.. please
Destroys the purpose of VCS
not sure, i dont use github
i dont like github
Okay then what do you use. GitLab?
just git
At the end of the day it shouldn’t matter
on a remote server
Ic
i could make him keys... but then yeah
i suck at that
i need about 6 simple plugins
and one big bungee plugin, which i might pay someone tbh
but the half a dozen or so i planned todo myself.,.. since it's really just "spectate on death"
i could use premade plugin and mod the config but then i feel like im wasting ressources... since i never wanted this plugin todo more
also i have stupid ideas like recompile paper and skip the saving step, to save time
so it restarts even faster...
Hey quick question… when I make a map in config.yml how do I put it in a HashMap to use in code?
Mind showing what you mean by "map in config"?
like key:value ?
getValues can get you a map
Example:
private Map<String, Integer> loadSomeMap(final FileConfiguration configuration) {
final Map<String, Integer> data = new HashMap<>();
final ConfigurationSection section = configuration.getConfigurationSection("items");
final Set<String> keys = section.getKeys(false);
for (final String key : keys) {
final int value = section.getInt(key);
data.put(key, value);
}
return data;
}
"loadSomeMap"
this is the type of method names that make it into my final code 
lul
lmao
🤸 🏌️
What do I put in when I call the function like loadSomeMap( ? );
The config file?
can someone please tell me how to prerender a map ? I would like to render a map at custom location with a red cross, I already have the map with location and the cross, but I don't know how to prerender it before I give it to the player, alternately if it is possible to render it as a mansion map it is good as well
MapView map = Bukkit.createMap(Bukkit.getWorld("world"));
map.setCenterX(0);
map.setCenterZ(0);
map.setTrackingPosition(true);
map.setUnlimitedTracking(true);
map.getRenderers().clear();
map.addRenderer(new MapRenderer() {
@Override
public void render(@NotNull MapView mapView, @NotNull MapCanvas mapCanvas, @NotNull Player player) {
MapCursorCollection cursors = new MapCursorCollection();
cursors.addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 12, MapCursor.Type.RED_X, true));
mapCanvas.setCursors(cursors);
}
});
ItemStack m = new ItemStack(Material.FILLED_MAP);
MapMeta mm = (MapMeta) m.getItemMeta();
mm.setMapView(map);
mm.setMapId(map.getId());
m.setItemMeta(mm);```
I saw this piece of code on the forum but I don't know how to acces the WorldMap object
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 128; ++y) {
mapCanvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
}
}```
so you suggest me to put a random byte to check if the map get fully colored ?
I try
ok it works
but it is fine for painting
I want to render the actual region
how can I know the right color ?
it would be a performance's eater if I try to check each higher block of each x:z 🤔
I'm having the stupidest issue right now
It doesn't print the "Made util" line
Does anyone know wtf is going on?
do you establish your sql connection ?
nice
sorry had something come up and I forgot, https://paste.md-5.net/cohazifuxe.coffeescript
anyway, if anyone else knows why the falling block doesn't show it would help :)
why do you use nms to spawn a falling block ?
datawatcher
didn't fully read my bad
you sure P() is the spawn entity packet?
because I need client sided falling blocks that don't interfere with other events in the server
anyway yes 7smile7 told me to use it and if you look into the P() it's a spawn out packet
Have you tried spawning the fallingsand manually?
Weird
Okay so it's a metadata issue
idk maybe
idk how to do this with NMS but I know how to do it with protocollib
you can link me up to the protocol lib lines I guess I will look into the protocol lib code
it's kinda weird doing entity metadata
Copy the EasyMetadataPacket stuff
add BlockPosition stuff
how do i detect if a player puts a helmet into their helmet slot like this? http://prntscr.com/1qkyfzt
cuz it can tell if its shift clicked in
but not if its dragged in
inventory click event?
it is an inventory click event
On the Spawn entity packet, you'd need to do the data stuff too
yh yh will test it out
idk what the block metadata stuff is
can someone please help me with my problem ? #help-development message
i cant rly get this thing to work so is checking every millisecond if the players helmet is a custom item a bad idea?
idk the falling block still spawns invisible for some reason
Did you set the block id on the spawn packet?
yup
packet.getIntegers().write(3, Block.getCombinedId(iBlockData));
into the spawn packet?
How would i make dynamic events
like I want to make a class where i can pass in a lambda and a event class and it would register an event that runs the lambda
take a look at that for example on how Conclure does it
Does anyone know if there is a place with documentation about net.minecraft.server package code ?
hmm I still cannot get the falling block to be there for some reason :/
Weird
Try debugging the sent packets and spawning some the bukkit way
and seeing what you're doing wrong
also keep in mind the spawn entity packet is weird
and has an EntityType you gotta override
Legit how I figure client-side entities is just debugging the spawn and metadata packets
Server version?
1.16.5
oh
Also try this
packet.getEntityTypes().writeSafely(0, EntityType.FALLING_BLOCK);
that is in which packet?
Spawn
don't think it has getEntityTypes
Send full code
like the updated packet handler class?
yeah
anyone know whats wrong with this?
for(ItemStack i : p.getInventory().getContents()){
if(i.getItemMeta().getDisplayName().equalsIgnoreCase("Miner Helmet")) {
if (i.getItemMeta().equals(ItemManager.wornMinerHelmet)) {
i.setType(Material.GOLDEN_HELMET);
i.setItemMeta(ItemManager.minerHelmet.getItemMeta());
break;
}
}
Also one thing you're doing wrong is
You need to write the 3rd integer on SpawnPacket as the block combined id
ok im doing if(i.hasMeta)
ehh not using nbt tags
spawn packet goes out of range on the 3rd field
oh dang im checking if the getitemmeta is an item not an item meta
f still invisible lmao
dont compare item names for custom items
i know
you don't even know how many times I heard the landing sound now
again it was a debug thing
lmao
at me.gamma.mininghelmet.mininghelmet.MiningHelmetFunctionality.run(MiningHelmetFunctionality.java:31) ~[?:?] help
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.hasItemMeta()" because "i" is null
a -> EntityId
b -> EntityUUID
c -> x
d -> y
e -> z
f -> velX
g -> velY
h -> velZ
i -> pitch
j -> yaw
k -> EntityType
l -> data
i is for(ItemStack i : p.getInventory().getContents())
it tells you whats wrong
instead of writing 31 try writing the block id
as the EntityType is the thing doing the ids
so should i do if(i != null)
yes
alr
or, if (i == null) {
continue
}
hmm you mean instead of 26 writing what exactly?
but that would continue only if the itemstack is null
?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.
Block.getCombinedId(fromMaterial(Material.STONE)) for example
yo imaginedev can you create a thread for this as it's quite complex?
i cant create threads atm
ehh ok
f
so yeah use the data fields
packet might trip so just
PacketPlayOutSpawnEntity spawnpacket = new PacketPlayOutSpawnEntity(
ENTITY_ID++,
UUID.randomUUID(),
location.getX(),
location.getY(),
locaiton.getZ(),
location.getPitch(),
location.getYaw(),
EntityTypes.FALLING_BLOCK,
Block.getCombinedId(fromMaterial(Material.STONE)),
Vec3D.ORIGIN);
and send it manually
okay let me try it out
omg
it works
bruh I spent a day on this stupid falling block lmao
sure thing
and maybe follow me on spigot so I can say I'm famous
change Vec3D.ORIGIN to new Vec3D(xVel, yVel, zVel)
yeah I will need to do some weird stuff besides that initial one, will ping if anything
what is the spigot user link?
just google my name as I'm synced
which item slot is the helmet? ive looked at multiple sources and theyre all different 🤔
yup followed
iirc it started bottom -> top so it should be 40
when said 103, one said 5, one said 36...
im so confused
yh
this is the current one
best skin
lmfao
copied off google
yh soo... the initial velocity vector does nothing lmao
Regarding PlayerInteractAtEntityEvent does it fire as well as Armorstandmanipulateevent ? or is it one or the other?
its wierd because the JD says Note that interacting with Armor Stands fires this event only and not its parent and as such users are expressly required to listen to this event for that scenario. referencing the PlayerInteractAtEntityEvent
I would have thought the Armour stand event
Hi, is there a plugin that randomly creates a scoreboard that counts a random blocks crafted ? Or I have to manually do it ?
I wanna do that each round you need to mined a new block to win in a normal generated world
No. Nobody is going to have a plugin that specific. You will need to make it or ask someone
Maybe later I can
@wintry radish if you want me to make it dm me the info and I'll make it when I have time
its the character for me
is config.yml safe for passwords and stuff? like how some servers ask you to sign up and login when u connect
im guessing its not
Is there a way to tell if a chunk is eligible for Random Ticks? Other than, of course, regularly checking if a player is in range? ChunkUnloadEvent is too far away
How do I create a new main world with new seed
Not in the slightest
public void onClamp(final PlayerInteractAtEntityEvent e) {
Player player = e.getPlayer();
final Entity clickedEntity = e.getRightClicked();
if (clickedEntity instanceof Player) {
ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
ItemMeta meta_kelepce = kelepce.getItemMeta();
meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
meta_kelepce.setLore(lore);
meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
kelepce.setItemMeta(meta_kelepce);
if(kelepce.isSimilar(player.getInventory().getItemInMainHand())) {
player.sendMessage("blabalbla");
player.openInventory((Inventory) clickedEntity);
}
}
}```
Nothing that stores passwords in plaintext is a good idea
You should salt and hash them
If you do that, then sure, store them in a yaml, it doesn't matter
i want to right click a player with custom item and open his inventory
Most likely the item comparison is failing
Add debug output
And keep a single instance of the special item instead of recreating it everywhere you need it
how can i take this custom item from another class
How do I create a new main world with new seed
help
This never gets less exhausting
- make it a static final
- make it available through your main class and pass that in the one ur working with through a constructor
- you should not cast an entity to an inventory to open it? cast it to something that has an inventory and then use #getInventory
static final ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
ItemMeta meta_kelepce = kelepce.getItemMeta();
meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
meta_kelepce.setLore(lore);
meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
kelepce.setItemMeta(meta_kelepce);
}```
should be like that?
?
how can i make 3
no i meant
your items should be like that
in another class
yes this is another class
and then u can refer to them with Namespace.item
ur making all ur variables static final
wait nvm I'm blind lol
ud have to look at the documentation
this class have bunch of errors
because u should put it in a method
and make that return an itemstack
have a look at that
i know methods
i just know where to use them
did
now i need to create constructor on Utility.java ?
that's if u went with step 2
now u can access them from the other class with Utility.thing
empty constructor
?
private ItemStack kelepce;
public Utility(ItemStack kelepce) {
}
public void utiliyty(){
ItemStack kelepce = new ItemStack(Material.TRIPWIRE);
ItemMeta meta_kelepce = kelepce.getItemMeta();
meta_kelepce.setDisplayName(ChatColor.GRAY + "Kelepçeler");
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.DARK_BLUE + "Polislere Özgüdür");
lore.add(ChatColor.DARK_BLUE + "Kişileri Kelepçeleyip Soymaya Yarayabilir.");
meta_kelepce.setLore(lore);
meta_kelepce.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
kelepce.setItemMeta(meta_kelepce);
}
}```
should be like that?
i dont know what type constructor do i need to use
public Utility(ItemStack kelepce)
or empty constructor like
public Utility()
parameter one does nothing and your empty constructor should throw compile errors
i need to use ItemStack parameter? i mean on constructors parameter
so you just answered your own question then
but then if i need to use this constructor another class it wants me a ItemStack parameter on ()
You always have to give it an itemstack doesn't matter where
?
how do i play a sound to a player through bungeecord
I mean an ItemStack instance
Send a packet
Handcluffs handcluffs = new Handcluffs(TO HERE RIGHT?)
what packet
PlaySound I think it's called
how do i send a packet in bungee
to that space right
You can use Protoclize
protocolize or make your life easier and just send a message to the sub server
would anyone be able to direct me to a resource in NMS where i make mobs head back to a certain location
bit of an ask but i cant find a resource anywhere
Back to a certain location???
yeah like
simple context, i have a bear bos
if it chases a player it will fall off
i need to TP it back i it falls off the mountain
and i need it to walk back to its cave when possible to avoid the above
whats the bukkit way of doing it
as far as i know if you give it a set of pathfinders to follow or rules on the move function it shoudl be fine
i dont think bukkit has a way to do it
No for the teleport
Pathfinding has to be NMS
Anyway NMS should have a teleport method too
Hi is there a way for recipe exact choice that if you rename your custom item it not broke the craft ? (my custome item has persistan data container, CMD etc...)
im assuming i just save a location, get the bukkit entity's handle, calc it's location na dsee if its too far
but i feel like that will be laggy considering how often it runs
Hey! Does anyone happen to know how to set the direction of stairs? I have already tried with the following code:
location.add(1,4,4).getBlock().setType(BRICK_STAIRS);
Stairs stairs1 = (Stairs) player.getWorld().getBlockAt(location.add(1,4,4)).getBlockData();
stairs1.setFacing(BlockFace.WEST);
player.getWorld().getBlockAt(location.add(1,4,4)).setBlockData(stairs1);
but then I get the following error through the console: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.type.Stairs
This refers to the following line:
Stairs stairs1 = (Stairs) player.getWorld().getBlockAt(location.add(1,4,4)).getBlockData();
can anyone help me there by any chance?
@waxen plinth Hello ! I'm looking at your lib ItemTrait class. I think TYPE comparison will not work fully on <1.13 versions (because the data byte should be part of this comparison in those versions). It may also be the case for DURABILITY. Since I did not tested it nor need this modification, I did not created an issue on your repository. I just want to ask you the question : Am I right or will TYPE and DURABILITY comparison work even on 1.12 ? ( https://github.com/Redempt/RedLib/blob/master/src/redempt/redlib/itemutils/ItemTrait.java )
Btw congrats for the lib. It's a very good work you've choose to share freely and open source with the community !
Are you sure that the BlockData you are casting there is actually of type Stairs? Before casting you should always make an instanceof check.
In 1.13 the data byte was already dropped.
Oh you mean <1.13
package Smile;
import org.bukkit.Bukkit;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Smile extends JavaPlugin {
public void onEnable () {
}
public void onPlayerChat (AsyncPlayerChatEvent event) {
event.getMessage (). equals ("2");
}
}
?paste
help
Please
- You forgot the
@EventHandlerannotation - You forgot to implement Listener
- You didnt register the Listenr
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
sekond
Sadly you cant define a custom Predicate<ItemStack> as ingredient. There is a workaround but it requires some work.
No not second. All of them.
i'l already doing it but just that broke everythins when you rename it
cause it need to be exaclty the same item has register
Yes. The workaround is a custom handler that is mapped to a MaterialChoice recipe.
Where you can define your custom Predicate<ItemStack> as ingredients.
indeed. Is this method to check the equality of 2 ItemStacks working on both mc == 1.12 and mc >= 1.13 ?
public boolean hasSameDurability(ItemStack a, ItemStack b) {
if (a.hasItemMeta() != b.hasItemMeta()) {
return false;
}
if (!a.hasItemMeta()) {
return true;
}
boolean isADamageable = a.getItemMeta() instanceof Damageable;
if (isADamageable != (b.getItemMeta() instanceof Damageable)) return false;
if (!isADamageable) return true;
return (((Damageable) a.getItemMeta()).getDamage() == ((Damageable) b.getItemMeta()).getDamage());
}
anyone may help find spaghetti? its prob all my code but some solutions or suggestions of what i can do are really appreciated https://github.com/2Hex/Teams
i was only trying to get the plugin to work, now its working fine i think i can start improving the code
yeah ik my chatevent is inside of my cmds
class
dont bully pls
How can this exist?
the return value of "org.bukkit.inventory.PlayerInventory.getItem(org.bukkit.inventory.EquipmentSlot)" is null
No I mean how can that happen when the getItem is @NotNull ?
player.getInventory().getItem(equipmentSlot).getType()
I check the equipmentSlot var and it isn't null tho
well that's just a constant for
it will always result in totalEXP being increased by the same amount
run the code, see the increment, and just totalEXp += that amount
The ItemStack returned by this method can be null.
getItem() returns null
hashmaps dont support null values
Ah wait. They support null values.
.
Why do you want to set null values in there?
cuz
can u tell me how to do this
Do you want == or .equals()
I need more context. What are you trying to achieve?
totalExp += ((50.0 / 2.0) * level * (level + 1));
I think
Here for reference
https://math.stackexchange.com/questions/1477878/formula-for-summing-up-incrementing-number
Ok. But why. Can you please paint a picture (metaphorically) so i can
suggest you a better solution?
hard to explain
this is the best way
Im 99% sure that setting null values in a map is never the "best way"
At least try to explain
my bad that was getLevel(player, type) not the level variable
int level = getLevel(player, type);
totalExp += ((50.0 / 2.0) * level * (level + 1));
I need to know if, in spigot1.12, there is a way to know if I should use the data byte when comparing ItemStacks type.
For example :
- wool can be colored so I want to check data to be sure the ItemStack has the same color.
- a redstone block can't be colored so I don't want to check the data.
- a helmet is not colorable so I don't want to check the data. Moreover, if I do I may compare durability and I don't want that.
I tried to code this but I'm unsure that it will work :
public boolean isTypesEquals(ItemStack a, ItemStack b) {
if (a.getType() != b.getType()) return false;
if (VersionResolver.getNms().getVersion() <= 1.12) {
boolean isAColorable = a instanceof Colorable;
if (isAColorable != (b instanceof Colorable)) return false;
if (!isAColorable) return true;
return (((Colorable) a).getColor() == ((Colorable) b).getColor());
}
return true;
}
why cant u just tell me
I could ask you the same...
because
its hard to explain
and i just wanna know
how to do it
map.removeIf(a!=null && a.equals(player));
Example:
private final Map<String, Player> somePlayerMap = new HashMap<>();
// PS this is dirty. Dont do that
public void nullifyAllValuesThatEqual(final Player player) {
for (final String key : new ArrayList<>(this.somePlayerMap.keySet())) {
if (this.somePlayerMap.get(key).equals(player)) {
this.somePlayerMap.put(key, null);
}
}
}
He wants to explicitly set the values to null and not remove them
Dont ask me why. He didnt want to elaborate,
sorry to bother again... I'm still stuck on making a map from last night... the "final Set<String> keys = section.getKeys(false);" isnt working for me.
map.replaceAll((k, v) -> (v != null && v.equals(player)) ? null : v);
in that case then
I wonder if this is reflected in the actual map:
public void nullifyAllValuesThatEqual(final Player player) {
this.somePlayerMap.entrySet().forEach(entry -> {
if (player.equals(entry.getValue())) {
entry.setValue(null);
}
});
}
I think so
It worked for me. Show me your code and your config pls.
Just to make sure you got this:
This is dirty programming and should be avoided.
null values can be handy in a map
though can definitely lead to unintended consequences
I have never even once seen a map with null values.
Maps return null if the key doesnt exist so this is indistinguishable from just no entry.
What's the error tho?
containsKey differentiates
What did it print?
Ok so first:
Dont constantly load values from your config on runtime.
- Load all data from your config into data structures when the server starts (onEnable)
- Use them on runtime
- Save them back to the config when server stops (onDisable)
Yes but this method is unnecessary overhead anyways. Ive not used it in ages.
if you know what you're doing having null values can be useful
probably not what this person wants, but it is a valid approach sometimes
Yes FileConfiguration is just a Map<> internally. The problem is that parsing the pathes still leads to some overhead
and weakly consistent keys like Strings are error prone.
Hm. Could you give an example? Maybe i can make use of that at some point.
I've used it previously but forget how I did
here's an example from SO
One example of usage for null values is when using a HashMap as a cache for results of an expensive operation (such as a call to an external web service) which may return null.
Putting a null value in the map then allows you to distinguish between the case where the operation has not been performed for a given key (cache.containsKey(someKey) returns false), and where the operation has been performed but returned a null value (cache.containsKey(someKey) returns true, cache.get(someKey) returns null).
The benefit of storing the value null against a key in a HashMap is the same as in databases, etc - you can record a distinction between having a value that is empty (e.g. string ""), and not having a value at all (null).
Ah i see. That makes sense.
not sure I understood... something like this? so it loads at onEnable and then I can use with Main.map ?
seems weird...
Usually you want to spread your data into new classes and give them proper names.
eh I just need it to work xD. It cant be that bad....
Dont make it "just work"
well after it works I can make it look better... it just doesnt work at all sooo...
I'm just trying to get a map of Materials, Integer from a config file 😢
If you use a clean approach you will make the process of figuring out how it works faster.
ugh I'll do a class then
So the weird thing was that at the very start you already have 50 totalExp?
Also once you reach level 2 it jump another 50?
Here is a template:
public class ItemData {
private final Map<Material, Integer> itemDataMap = new HashMap<>();
public void addValue(final Material material, final int value) {
this.itemDataMap.put(material, value);
}
public int getValue(final Material material) {
return this.itemDataMap.getOrDefault(material, 0);
}
public void loadFrom(final FileConfiguration configuration) {
// Load your map data from the config
}
public void saveTo(final FileConfiguration configuration) {
// Save your map data to the config
}
}
private ItemData itemData;
@Override
public void onEnable() {
this.itemData = new ItemData();
final FileConfiguration configuration = this.getConfig();
this.itemData.loadFrom(configuration);
}
@Override
public void onDisable() {
final FileConfiguration configuration = this.getConfig();
this.itemData.saveTo(configuration);
this.saveConfig();
}
@quaint mantle
int level = getLevel(player, type);
totalExp += ((reqEXP / 2.0) * (level - 1) * level);
try this then
my problem is the loadFrom part. I understand the part of changing/saving the config file but how do I load it...
you need to work out what data you need de/serialised
save that
and whether you save it as json, or more like yaml is up to you
how can I make a text like yours?
```java
code in here
```
make sense?
wow
package Smile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class Handler implements Listener {
@EventHandler
public void onPlayerChat (AsyncPlayerChatEvent event) {
event.getMessage (1). equals ("2");
}
}
not working
public void loadFrom(final FileConfiguration configuration) {
final ConfigurationSection dataSection = configuration.getConfigurationSection("items"); // Get the section
if (dataSection == null) { // Check if it actually exists
return;
}
for (final String key : dataSection.getKeys(false)) { // Go through all keys in that section
final Material material = Material.matchMaterial(key); // Translate the key to a Material
if (material == null) {
continue;
}
final int value = dataSection.getInt(key); // Get the value mapped to that key
this.itemDataMap.put(material, value); // Put both in the map
}
}
public void saveTo(final FileConfiguration configuration) {
final ConfigurationSection dataSection = configuration.createSection("items");
for (final Material material : this.itemDataMap.keySet()) {
final int value = this.itemDataMap.get(material);
dataSection.set(material.toString(), value);
}
}
help
Let your IDE format your code pls
Ctrl + Shift + F
Im sry but this code looks like you didnt take the little time that is required to learn at least the very basics of java.
public class Handler implements Listener {
@EventHandler
public void onPlayerChat (AsyncPlayerChatEvent event) {
event.getMessage (insert here what he writes?). equals ("and what will be displayed here?");
}
}
what are u even trying to do.
Just boolean lol
it is, but I need to make this plugin now
🤣
when you enter 1 into the chat, 2 was displayed
so... I do "loadFrom(config)" in my onEnable command. So it creates the map. Then I can just use ItemData.getValue(material) to get stuff?
loadFrom(this) would mean that you want to pass a JavaPlugin variable to your method.
What type does the method loadFrom() take?
can I just do this? and change the function to static. I'm not even sure what a "FileConfiguration" is
ItemData.loadFrom(config) is almost correct.
but loadFrom is not a static method. This means you cant just call it from the class reference.
You need to create an instance of that class first. Avoid all static for now.
An instance of a class can be created using the new keyowrd
so I make a constructor in the ItemData class?
sorry, of course, but what are you talking about?
Every class has an implicit constructor by default. You could make one but you dont need one.
You can just create an instance with new ItemData()
Yes. Nice
and now I'm supposed to have a map?
The map is inside the instance of your ItemData class.
Every time you create an instance of a class, all the fields and methods inside
the instance are created.
So you can have several instances of ItemData
final ItemData dataA = new ItemData();
final ItemData dataB = new ItemData();
And each instance will have their own content. Completely new.
You can now call all the methods you created in your ItemData by just using
instance.method(params)
how do I load it in another class if its not static?
Like getting the ItemData in my Listeners class
Other classes that need an instance of this class should request that in their constructor.
So if you want the exact instance you loaded your config into, in another class you need to
pass it via the constructor.
public class SomeListener implements Listener {
private final ItemData itemData;
public SomeListener(ItemData itemData) {
this.itemData = itemData;
}
@EventHandler
public void onSomething() {
// Use this.itemData to access the data
}
}
Then you pass this exact instance to other classes.
final ItemData dataA = new ItemData();
dataA.loadFrom(config);
SomeListener listener = new SomeListener(dataA);
Bukkit.getPluginManager().registerEvents(listener, this);
Just make sure you dont have new instances for different classes. You want
this instance everywhere.
kk think I did it, now in my "SomeListerner" class. How do I call the map. cant seem to find I'm just testing stuff
You dont want to get the map directly.
the ItemData class has methods that access the map. But the map itself is never exposed.
Material material = ...; // Get Material from event somehow
int materialValue = this.itemData.getValue(material);
Yes, I am sure. I set the block with location.add(1,4,4).getBlock().setType(BRICK_STAIRS); and then get the BlockData from the same coordinate. player.getWorld().getBlockAt(location.add(1,4,4)).getBlockData();
Sysout the type of the block and make an instanceof check.
Btw you should get this in the BlockPlaceEvent.
Two spaces.
Material enum is in all caps.
items:
GOLDEN_APPLE: 12
STEAK: 420
the prob is I might want to get difference between enchanted golden apple and normal golden apple
store damage of item
is not saying anything
Enchanted golden apple has its own type
items:
ENCHANTED_GOLDEN_APPLE: 1000
GOLDEN_APPLE: 12
STEAK: 420
😢
More code pls
Before we pursue your problem:
Free your code from all the static keywords.
Make Main plugin private final and non static and request it via the constructor.
Btw you register your listeners twice.
Remove the registration in the constructor,
oh yep... removed
You should also see an exception in your console. Because your config will always be null.
You created a variable but never put anything in there. So it will always be null.
Check your console for exceptions when the server starts.
does anyone has an idea for me ? https://www.spigotmc.org/threads/how-to-prerender-a-map.523281/
You declared your config variable. Which will make it null by default.
Then you put nothing in there.
Then you used it. -> null pointer
Did you make sure that all chunks at that location are 100% loaded?
should I put something in it at like my onEnable or just in my Listener
check my answer in the thread
In you onEnable you should load your default config.yml into that field.
So this.config = this.getConfig();
kk
Use plugin chunk tickets.
- Add tickets in a radius around the center
- Render the map
- Remove all tickets from the chunk again
hmm so I got a message for eating a GOLDEN_APPLE in game but its 0 not 12... good start tho 🙂
How does your config look like?
config.yml looks like this
assuming itemdata.getValue is a function you wrote, would you mind posting the code?
what are tickets ? I'm trying to find out on the forum and the chunk doc but can't really understand
Looks good.
At this point you need to start adding debug messages in your code and see whats wrong.
"I wrote" 🙂
You add a ticket to a chunk to load it into memory and even generate it if its not already generated.
This way you can make sure that the chunks you want to render are actually in memory right now and dont get
unloaded until you remove the plugin ticket again.
so I don't have a keySet I guess that would be a problem 🙂
You should try debugging that so you understand whats happening in there.
Just add some System.out.println() into the code and print out different infos like
the the materials that are laoded, what values where loaded etc
How do you think minecraft renders a map? They dont pull the data out of thin air.
The chunks that are rendered have to be loaded.
ok
This means the map is empty.
Assuming the issue is where i think it is, it either thinks you're loading the wrong/an empty config, or not loading in the HashMap correctly. Do what 7smile7 said and add console logs at key points - for example, print out the result from dataSection.getKeys(false)
also are you using the correct config file?
Debug your loadFrom method. Put a bunch of Sysouts in there.
Is the section retrieved or null? are any keys in the section? etc.
idk theres only 1 config file. so I think so
yep doing that
I think i know the problem but let him figure it out
oops
Ah that one we fixed already.
I think the code itself is fine btw. The problem is probably related to the config.yml
the config looks fine tho
?
what is 76
that number isnt even in your code is it...
lmao no
Yes but is it actually deployed?
Yeah but that doesnt mean its loaded from/saved to disk
?...
how do you guys assign the config atm?
um
it should work when you start theplugin twice
urgh
youre first assigning the variable but that code should save the config to the disk
im unsure if this could cause problems here
but it shouldnt
well im out of ideas

- assign variable
- save the file to load
hence
start it twice
I have no clue what cause the empty areas
Render the map some ticks after you added the tickets. Maybe 5 or so.
using the this keyword is totally fine.
actually I add tickets to every chunk in the area, I stock them in a list, I render the map, then I unload the tickets through the list, is it wrong ?
Just make sure that you remove the tickets after the render inside of your runnable!
I mean. You dont need it here so you can also just get rid of it.
Imagine naming it main
dumb question of my own now:
saveResource(configFile, false);
return YamlConfiguration.loadConfiguration(new InputStreamReader(getResource(configFile)))
This should just save the resource to the disk and return said file right?
...why is it the second i ask something everyone is just gone
No this saves some file (whatever configFile is) to disk and load the config from inside the the jar
well that still results in the same as if i would load that file in right?
ok so I feel like the problem is that my config file like "GOLDEN_APPLE" is not saving as Material.GOLDEN_APPLE
But this means nobody will ever access your config file as you always load it from inside your jar.
So no point at saving it to disk in the first place.
Hey 7smile, I have noticed what you mean about the creative mode being unreliable. 🥲
ah well its inside a function that first checks if that file already exists. I figured it would be easier doing that than to add the 20 lines of code to load in a file from disk
All you need is this:
private ItemData itemData;
@Override
public void onEnable() {
this.saveDefaultConfig();
this.reloadConfig();
final FileConfiguration configuration = this.getConfig();
this.itemData = new ItemData();
this.itemData.loadFrom(configuration);
final SomeListener listener = new SomeListener(this.itemData);
Bukkit.getPluginManager().registerEvents(listener, this);
}
@Override
public void onDisable() {
final FileConfiguration configuration = this.getConfig();
this.itemData.saveTo(configuration);
this.saveConfig();
}
7smile, has creative mode always been unreliable for these things do you know?
Then provide a config.yml inside your plugin.
Just make sure to not change the config while the server is running.
@lost matrix I still get the same result, what am I doing wrong ? https://paste.md-5.net/behaqapeva.java
update is called every tick
Its not unreliable but client authoritative. This makes it really hard to handle server side.
Ah, I see.
so you're scheduling a new method 5 ticks later, every tick
what are you trying to do?
If only it was handled the same way as survival 🥲
I thought you said you only wanted to render the map once...
of course once
you could try merely adding a boolean of whether it was rendered or not
is this good enough for a config.yml inside my plugin
Ask mojang why its not. I mean there are reasons.
if it has, return
ah fuck used the wrong xD
oh lol
Should be fine.
what should I use then ?
... still showing that keySet is empty tho
your config.yml isnt in your ressources folder i think
keySet has no materials
If you don’t use a build tool the config.yml should be in the root folder
to be fair i dont exactly know how eclipse works but still
Use the update method but add a boolean after the first call and just return if its set.
public void update(MapView mapView) {
if(this.alreadyRendered) {
return;
}
ArrayList<org.bukkit.Chunk> chunks = new ArrayList<>();
Doesnt need to be. He doesnt use maven.
src path is fine
i prefer to use maven if just for the fact that it's typing three words and done
like this ? https://paste.md-5.net/pexexohunu.java
(I have reduce the chunks number to test quickly, btw it still bugging)
and I didn't understand why you said that it was rendering every tick
it seems to be correct to execute once 🤷♂️
How do I sysout stuff in the ItemData folder?
anyone know why i can't do team.setColor outside the createRank method?
public class Teams implements Listener {
public static Team createRank(String name) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Team team = board.registerNewTeam(name);
return team;
}
Team team = createRank("OWNER");
}```
or any other option
if(rendered) {
return;
}
rendered = true;
Set it directly after the first call.
still bugged
Write a constructor. You cant just call methods in a blank class
still don't know what a constructor is, also i swear to god if you say learn java i will block you
Show your current code and outcome pls
Then there is nothing to add here.
@lean gull only variable declaration is allowed outside of scope (what you're doing)
You cant.
Team is a local variable, so you can’t access it outside that method
ok so what do i do
the code is ran "all at once", if it's not in a method, so there is no order to it, so you can't add on to it
?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.
Create a constructor.
here is the outcome, I have reduced to 16x16 chunks to go faster
again, i do not know what a constructor is
Then you cant do what you are trying to do.
MapView map = Bukkit.createMap(Bukkit.getWorld("world"));
map.setCenterX(0);
map.setCenterZ(0);
map.setTrackingPosition(true);
map.setUnlimitedTracking(true);
map.getRenderers().clear();
map.addRenderer(new MapRenderer() {
@Override
public void render(@NotNull MapView mapView, @NotNull MapCanvas mapCanvas, @NotNull Player player) {
MapCursorCollection cursors = new MapCursorCollection();
cursors.addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 12, MapCursor.Type.RED_X, true));
mapCanvas.setCursors(cursors);
}
});
new MapUpdater(Bukkit.getWorld("world")).update(map);
ItemStack m = new ItemStack(Material.FILLED_MAP);
MapMeta mm = (MapMeta) m.getItemMeta();
mm.setMapView(map);
m.setItemMeta(mm);
m.setDurability((short)mm.getMapId());
p.getInventory().addItem(m);
that's how I create the map, then here is how I try to load it: https://paste.md-5.net/uputuqivep.java
Hm. Does it always look the same when you restart the server?
yup
Ok then its a systematical error.
So if you delete the map, restart the server then the map looks exactly like the one before?
yes
Ok
but I copy paste the same world before restart
do you think the world is the problem ?
If you did load all chunks with a ticket then not.
my code is exactly as it is in the paste
setPositionRaw(x, 0., z); have you tried playing with the y coordinate?
x += 64
You increment by 64 even when the map is 16x16
@calm whale
Wait this is scale dependent, right.
yep
Those are my 3 takes:
Increase delay from 5 to 10 ticks
play around with the raw y position
change the increment based on your maps size
I don't think the y matters, the proof is that we get some parts of the map
This only proofs that some parts of the map work with this y value and others might not
what do you suggest ? use the higest y ?
running getRenderers().clear() doesnt remove the renderers
you have to use removeRenderer
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
I have a stick in my hand.
Interact is called for both hands
check the hands
also null check the item for good coding and when you aren't holding anything
i think this is a constructor, not sure, but i still can't use the options of the team
public class Teams implements Listener {
Team team;
public Teams(String name) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
team = board.registerNewTeam(name);
}
Teams owner = new Teams("OWNER");
}```
Maybe try 1 first.
^^^
Yes yes. And also properly clear the renderers list.
They should really make this immutable and throw an UnsupportedOperationException there.
event.getItem().getType()!=null && event.getItem().getType().equals(Material.STICK)
Can you do that more elegant in some way
Yes thats a constructor. What exactly are you trying to do
event.getItem != null
Yes. Create variables.
make ranks, change their color, prefixes, suffixes, stuff like that
Can’t call getType on a null item
thats the only place the item in hand is important
i was told to do that with teams
so chat won't be broken when you type something or just "%"
getType can't return null, getItem would
event.getItem() != null && event.getItem().getType == Material.STICK
code?
I came back on 32x32
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
ItemStack clickedItem = event.getItem();
if (clickedItem == null) {
return;
}
Material type = clickedItem.getType();
if (type != Material.STICK) {
return;
}
// You can be sure that the item clicked with is a STICK here
}
me ?
yes
well its easier to read but i meant elegant in the way of simpler
Ah now we can see a clear pattern.
xD it has always been the case
Nothing is more elegant than readable clean code.
Doesn’t really get simpler than that
If you want it to look a bit more fancy:
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
Optional.ofNullable(event.getItem()).ifPresent(item -> {
if (item.getType() == Material.STICK) {
// You have a stick here
}
});
}
Or you could make a util method I guess
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
ItemStack item = event.getItem();
if (item == null || item.getType() != Material.STICK) {
return;
}
// You can be sure that the item clicked with is a STICK here
}
Pass it an item and a material and have it return a Boolean
nah msws solution is thebest one her
as said i only need that item once and the null check is to prevent the npe
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
Optional.ofNullable(event.getItem()).stream().filter(this::isNotNullAndStick).forEach(this::handleStick);
}
private boolean isNotNullAndStick(final ItemStack itemStack) {
return itemStack != null && itemStack.getType() == Material.STICK;
}
private void handleStick(final ItemStack stick) {
// Handle stick here
}
XDD (dont use that)
you can stream an optional?
isnt .stream() a method of the object class?
still need help
Yes. Thats important for flatMaping
Nope
huh
no
no
it twice
how am i rude
?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.
and blocked
it has always been the case
lmao
It’s okay, they can’t block the truth
poor guy
im gonna take a wild guess and say that you guys think im rude because i block rude people?
he literally just told me to learn java
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.
?learnjava
ba da bing ba da boom, blocked
coll go learn
anyone else wanna tell me to learn java?
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.
This looks like 2 renderers fighting. One going from top to bottom and one
going kind of diagonally from top left to bottom right.
I know enoug about java to hate everything new after java 8 lol
so you dont
@lean gull learn java
you need to ?learnjava him
oh ok sure
otherwise you arent telling enough
There has been a lot of good stuff post java 8
learn java @lean gull
yea like 'record' is a interesting feature but its useless for dynamic data types
i know this will make yall happy so imma just leave this server, rude people everywhere and no one actually wants to help


you