#help-development
1 messages · Page 1752 of 1
Because I dont think it does
you are casting to the player so yes in that case please check if the entity is an instance of the player
java's instanceof keyword helps
Nevermind it's inside of the PlayerDeathEvent .
This is the relevant code:
public void onPlayerDeath(PlayerDeathEvent e) {
var player = e.getEntity().getPlayer();
boolean isPvpDeath = player.getKiller() != null;
// ...
}
kotlin ok
Can this really throw an NPE? Because I don't think it ever has
yes. it can possible throw an NPE.
In what situation would that happen?
Depending on your code, that error may occur. However, it is recommended to check for null.
But does PlayerDeathEvent fire for any non-player entities dying?
Ok but then how can it throw an NPE?
i told you
You said depending on my code it may occur. But I'm literally just getting the entity from the event. And you said the event only fires for players.
have you tried looking into when inside of bukkit's source is PlayerDeathEvent fired?
I only checked the docs. But Vaget said there are occasions when an NPE may be produced here, I'm just wondering what they meant
It's because you're getting a player from an entity
So it won't occur under that event
But getEntity() is annotated @NotNull and returns a player. So how can there be a NullPointerException when I use getKiller() on it?
is it possible to convert a Map<UUID, ItemStack[]> to a List<String>? i can get the string with the base64 converter but it doesnt really works for collecting it
Why would you want to put a whole map into a single String?
nah i just want to have a list with strings
something with foreach
so i can get the uuid too
bruh just create a new list and add your strings there with a foreach
ArrayList is good
isnt it possible with a stream?
How can I make a command that tells you how many totems you used? example: Server - Used Totems: 1
¯_(ツ)_/¯
something like
dataFile.set("safe-chests", SafechestGui.getMenus().entrySet().stream().map(entry -> InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));
i think i got it
private final Map<UUID, ItemStack[]> items = new HashMap<>();
public void writeToConfig(final FileConfiguration configuration, final String key) {
final ConfigurationSection section = configuration.createSection(key);
for (final Entry<UUID, ItemStack[]> entry : this.items.entrySet()) {
section.set(entry.getKey().toString(), Arrays.asList(entry.getValue()));
}
}
public void readFromConfig(final FileConfiguration configuration, final String key) {
final ConfigurationSection section = configuration.getConfigurationSection(key);
if (section == null) {
return;
}
for (final String uidKey : section.getKeys(false)) {
final UUID userID = UUID.fromString(uidKey);
final List<ItemStack> itemStackList = (List<ItemStack>) section.getList(uidKey);
this.items.put(userID, itemStackList.toArray(new ItemStack[0]));
}
}
You can just save a List<ItemStack> in a config path.
heh ```java
dataFile.set("safe-chests", SafechestGui.getMenus().values().stream().map(InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));
also how can i get a Player object from an uuid?
Bukkit.getPlayer(uuid) will return null i guess
it'll work as long as it is a UUID object
Hi I'm new and I'd like to know how to save maps!
I made maps but they obviously don't save themselves so how do I save them? (I mean what's the best way to save them? under files?)
https://github.com/Max094Reikeb/MaxiCity/blob/master/src/net/reikeb/maxicity/misc/Maps.java
so the player will not be null?
It will be null if they aren’t online
well i want to get a player object from offline players :/
hmm
offlineplayer represents an offline player 
in the playerjoinevent, the player is "online" right?
yes
The more you know
🧠
please could anyone help me? 🙏
yes
yesh
there
private HashMap<UUID, Integer> balance = new HashMap<UUID, Integer>();
private HashMap<UUID, Boolean> joinedPlayer = new HashMap<UUID, Boolean>();
private HashMap<UUID, Boolean> mutedPlayer = new HashMap<UUID, Boolean>();
private HashMap<UUID, String> mutedReason = new HashMap<UUID, String>();
private HashMap<UUID, Boolean> nickedPlayer = new HashMap<UUID, Boolean>();
private HashMap<UUID, String> playerNickname = new HashMap<UUID, String>();
private HashMap<UUID, String> playerTeam = new HashMap<UUID, String>();
private HashMap<UUID, Boolean> socialSpy = new HashMap<UUID, Boolean>();
private HashMap<UUID, Boolean> teamChat = new HashMap<UUID, Boolean>();
holy cow
so.... wouldn't it be easier if you made this a single class and just had one hashmap?
Please no. Please
Yes
that's a lot of hashmaps
it would be better
lol that entire classes just hashmaps, getters and setters
What they are saying is, theres much better ways to handle all of that
^
private final Map<UUID, PlayerData>
public void addBalanceToPlayer(OfflinePlayer p, int amount) {
if (balance.get(p.getUniqueId()) != null) {
balance.put(p.getUniqueId(), balance.get(p.getUniqueId()) + amount);
} else {
balance.put(p.getUniqueId(), amount);
}
}
use this instead
public void addBalanceToPlayer(OfflinePlayer player, int amount) {
balance.putIfAbsent(player.getUniqueId(), amount);
}
🐮
✝️ 🐮
also those hashmaps...
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityResurrectEvent.html
Use this, although now i think about it there might be a statistic
maybe a database or yml woild be better
There isnt
So you need to make a counter
check the players hands for a totem if the event is not cancelled
if there is a totem present, increment a counter
or just pdc? :p
attach the counter to the players pdc
then just query it on command
pdc?
How on earth is there not a statistic for that
?pdc
Dangit Mojang
thats what i thought
nah too much work for him

who even said me to use uuid in the chunk pdc smh
so if I don't use pdc what do I use?
youd have to manually save / read to file
well now I'm grouping all HashMaps into 1 class
you mean you're grouping the hashmaps into one hashmap, right?
yeah
like this
public class Maps {
private final HashMap<UUID, PlayerData> playerDataMap = new HashMap<UUID, PlayerData>();
public MaxiCity plugin;
public Maps(MaxiCity plugin) {
this.plugin = plugin;
}
public static class PlayerData {
private Integer balance;
private Boolean hasPlayerJoined;
private Boolean isPlayerMuted;
private String mutedReason;
private Boolean isPlayerNicked;
private String playerNickname;
private String playerTeam;
private Boolean socialSpy;
private Boolean teamChat;
}
}
you presumably want to use primitive data types over the boxed ones
so use int instead of Integer and boolean instead of Boolean
you create a getter
in PlayerData create a method like:
public int getBalance() {
return this.balance;
}
oh that is cursed now that I see it
lol
thx now all I need to do is the save/load from a file
mutedReason: the reason why the reason is muted
is the reason muted?
or not?
Hello! i'm trying to get a constructor from a class in other class with instances, but getting an error...
private final CriticalHits plugin;
public CritCancell(DamageIndicator plugin) {
this.plugin = plugin;
}
I have this in the class where i want to access, and this in the other class:
private final DamageIndicator plugin;
public CriticalHits(DamageIndicator plugin) {
this.plugin = plugin;
}
(DamageIndicator is the main class...)
uh that's weird it doesn't offer me to do anything to call this method elsewhere
And i'm getting an error in "this.plugin = plugin;" from the first code
well you'd call something like
playerDataMap.get(uuid).getBalance() for instance
Cannot resolve method 'getBalance' in 'UUID'
Hi there, sorry for stupid questions, but is there some way how to get the correct namespaced key of a custom biome instead of just minecraft:custom in 1.17.1?
the muted is reasonned
oh you're not suppose to call uuid.getBalance()
you give an DamageIndicator and you expect an CriticalHits???
let us mute all reason and make a hashmap within a hashmap within a hashmap within a list
DamageIndicator and CriticalHits are null in the code you've shown.
heh
yes... that's the error given to the console
You didn't assign a value to them, so they're null
but, don't know how to solve it :/
assign them a value?
so guys iam backing try make spigot plugins, i tyred on 1.6.4 with gradle, but for some reason i cant extend JavaPlugin
runtimeOnly files('libs/spigot-1.6.4-R2.1-SNAPSHOT.jar')
compileOnly
OK so now if what I did is good, then I need to find a way to load/save the main HashMap into a file
https://pastebin.com/JpL4uTXZ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
if ONLY java had a way to do this
What. The. Heck.
Who even plays 1.6 anymore
crafting dead
if only.....
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
Hello is better to use Persistent Data Container from spigot api or database for store many things on users ? What do you think ?
I'd say depends
the data becomes somewhat too coupled with spigot arguably
I used it for certain statistics like totem uses etc
but when it comes to non bukkit related data like permissions, economy etc I believe using another storage implementation is much more beneficial
But when do I need to serialize/deserialize? Each time after a player has his stats changed or each time the plugin loads/unload?
no import
i did lmao
theres no import in that screenshot
its same package
it’s registerEvents
^
thx
question, can i detect a MOD event using spigot or no?
or i will need forge for that?
Spigot doesn't support mods
okie thx
And Forge doesn't support plugins
https://pastebin.com/cbiYqSir
What should i put in my serialize() method?
Also, when do I need to serialize/deserialize? Each time after a player has his stats changed or each time the plugin loads/unload?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
does anybody use a vanilla weapons plugin that works for java and bedrock servers? it would add axes, katanas, daggers. also armor if possible. very few to 0 added ores.
Wrong channel
I think U need Mods for that
Stay in help server
Anyone know how to create PacketDataSerializer from scratch
constructor requires ByteBuf
but PacketDataSerializer is itself the extension of the netty AbstractByteBuf class
find players near mob inside creaturespawnevent listener
how can I use the worldcreator to make a world with no blocks, only air
Start by creating a chunk generator
sorry for the dumb question, but how do i do that
Is there a possibility to add a separate recipe category for the recipe book? I want that my friends have a good overview of my own recipes
what class should I look at?
Someone tell me how to do that when someone moves for a while die?
/fill ?
Nested loops
lol
I'm trying to make variables in vanilla minecraft. The idea is I could take this command:
give @s $varible 64
then, send that command to a custom parser that I would build, and replace $variable with whatever it's value (say, minecraft:stone). Then, after replacing the variable names with their values, run the newly parsed command as the sender.
Bukkit.dispatchCommand(p, parsedCmd);
// would essentially run "give @s minecraft:stone 64"
My question is: How do I intercept the command before the game parses it?
mhm
or does that give me the command first, that I can manipulate and then send on it's way
Read the docs
ok thank you!
BlockExplode is only when teh block itself is the source of the explosion
PrimedTNT is an entity
what are you trying to do?
then listen to the Entity explode event
I'm using NMS and my custom entity instantly disappears, what am I doing wrong?
Hello everyone !
I have a little question:
For some reason I use this method which allows me to force a player to execute a command.
Bukkit.dispatchCommand(player, "warp test");
The problem is that this system triggers Spigot's permission system.
I would like to know if it is possible to bypass the permissions plugin please?
NMS Entity Disappearing
The only way would be to op and then deop the player. This isn't very safe you should concider not using commands in your plugin like that
Generally that is the way plguins like citizens do it
Alternatively get a plugin that supports /warp player name
I see ...
I'm a bit sad
You can't change the blocks in the explode event. They are going to be removed and it finishes
what are you trying to do? Your code is nto clear
you have a copy of the area at +1000 x?
why?
ok, you need to run a task in the explode event, delayed...
you pass it the list of blocks
then when the task executes you copy from the reset map to the main map
yes
what
do u know how to apply a custom texture to a player skull?
I just cant figure it out.
You want to instantly restore blocks that get blown up?
Just remove any block that isn't in the resetmap from event.blockList
Use an iterator on event.blockList()
and call remove() if they aren't in the resetmap
?paste
im trying to sort my bounties according to their value, but it is not working. https://paste.md-5.net/dehefumipa.java
when i do map.values and use stream, they lost the ordering
using treemap
why not to just hook into Essentials
dispatching command for this seems like a code smell for me
wdym ?
is warp command from the EssentialsX?
ah nop it was an example xD
Have anyone used PacketDataSerializer before
i really struggle with this
right now
I'm trying to store data to a file, so that it won't reset when I restart. Can anyone point me to a good resource to help?
What data are you trying to store?
hello, i want to break wood with pickaxe, faster. Any ideas ?
maybe set block hardness ?
variables
I saw this one blog post by one of WorldEdit's contributors
yeah, that tells me nothing, everything is a variable
basically it said that, if you have information that ALL must be known at the start of the plugin, it should be saved locally via YAML/GSON/whatever
otherwise, if you have a lot of information and you only need some of it at a time, use databases
YAML it is lol
GSON's pretty easy tho
it all depends on what these "variables" are
it sound like few ms
yeah uses yaml
just strings then GSON
ok getting two answers here
Yaml isn't meant for data storage
it's used for config?
oh an nbt dictionary, thats diffrent
not an nbt dictionary, but just a dictionary
actually, no
probably just strings and ints
yeah it's probably just strings and ints
but in GSON you will got some problems like with locations or things like that
how so
that javadoc is unconventional
Oracle's official guide says you shouldn't do "the world", "the x", etc. since it doesn't provide any additional information
theme ?
it's quite colorful
eww Intellij
die
intelij >
there are basically no major issues with IntelliJ as far as I can tell :p
you tried modifying the properties of the pickaxe?
Material Theme UI
idk if it's possible for tool items but
it will do nothing, it will change for rock but it will not with wood
with attributes
Is there an easy way to desync player and the server for a little bit to test one thing
UDP flooder is all i can think of
How can I maintain compatibility across multiple versions (say, 1.8 -> 1.17.1) with Spigot's API?
Would I just need to declare a dependency on the minimum version I want to support?
Please could anyone help?
Yes, and don't have a api-version set
also: what is the minimum version worth supporting? I'm guessing either 1.8 (or else people will yell at you) or 1.13 (since it seems to be pretty stable, plus it means you don't have to deal with The Flattening)
I would say 1.8 or 1.14
1.13 doesn't really run that well, the spigot API for it was only available for a short time, and 1.14 has PDC
ooh fair point
How do I put a texture on a head?
I also have an issue btw
I use XMaterial with api-version set to 13
1.8 to 1.17 ez mode
I just compile it into materials at startup so I don't really have a metric for it
how'd you do that? custom code?
Just what XMaterial does
oh
getOrDefault not get
yeah but what's the default value then?
Can I fork Spigot and work on my own branch of it? I'm aware there's no support for that, but there are a few things I'm thinking about.
Yes
Execuse me
net.minecraft.world.level
In this package,there's an interface named IMaterial
I want to use it for net.minecraft.world.item.ItemStack
public ItemStack(IMaterial imaterial) {
this(imaterial, 1);
}
But I really don't know what is IMaterial
Currently im making a very simple home system, im using my player nbt data to store the coords and stuff i have that all working, how would i store my specific dimension in that? So if i set my home in the nether ill be able to have it send me to the nether location not all overworld
Store the name or UUID of the world
I edited my message a bit, would this still apply?
yes
config.yml help
Is it possible to force a player to walk? Like not just tp but i mean make them walk to X location
I was looking for builtin methods via keywords like "walk" but cloest i found was walkspeed and frost walk stuff
I feel like I've done it before and seen a plugin do it but am having a total brain dead moment like its staring me in the face
Does this help?
https://bukkit.org/threads/force-player-to-jump-or-walk.118771/
Thank you, its a bunny hole I'll start down at the least :)
Execuse me
net.minecraft.world.level
In this package,there's an interface named IMaterial
I want to use it for net.minecraft.world.item.ItemStack
public ItemStack(IMaterial imaterial) {
this(imaterial, 1);
}
But I really don't know what is IMaterial
Why
md_5, do you ever regret your life choices?
'i' stands for interface
You use org.bukkit.Material not IMaterial
Then just English in well, dumbaaaaaass
i was just wondering if i could upload a schematic file to a SQL database so i can load it on another server using hikaricp ofc (ping if it's possible :/)
How can I use GameProfile?
To use GameProfile, depend on spigot not spigot-api
i set my api version to 1.13, it is ignored in previous versions and stops later versions moaning about no api version set
Ah true
What do you mean? Sorry, im new to coding plugins.
then it would not be a good idea to dive straight into using GameProfile
he prolly want to make a nick plugin or so
oh ok
no im trying to make a custom skull texture
and it seems like you need GameProfile
uhh well, wouldn't advice going anywhere near that currently
ok
till you learn more about spigot api and java itself
even better
But The function public ItemStack(IMaterial imaterial) {this(imaterial, 1);} requires IMaterial
then you are using teh wrong ItemStack/method
I tried,But IJ said Required type:
IMaterial
Provided:
Material
sometimes i wonder how people come up with those things
What are you trying to do?
I'm trying to make new items through NBT
But it doesn't provide a function which can add custom nbt
bump
yes its possible
You could store it as a BLOB I guess
uh you are right but i think it could work faster if it's like that
could be wrong
i could have also done a gson.toJson
How would I go about making a 3-second countdown loop? (Before the minigame starts)
I've read about schedulers everywhere, but I still can't wrap my head around them
The plan is to sendTitle to all players as 3,2,1 but I don't know how to delay a loop.
I have this:
int offsetx[] = { 2, 2, -2, -2 };
int offsetz[] = { 2, -2, 2, -2 };
for (int i = 0; i < 4; i++) {
Entity e = killer.getWorld().spawnEntity(new Location(killer.getWorld(), center.getX() + offsetx[i],
center.getY(), center.getZ() + offsetz[i]), entity.getType());
e.setCustomName(General.colorize("&6Súbdito de Halloween"));
e.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
}
Code (in a EntityDeathEvent) to spawn some mobs but I think their metadata is not being set because
if(event.getEntity().hasMetadata("EL_Halloween_minion"))
(in a CreatureSpawnEvent) is not being recognized as true 😦
if my full code for the events is needed lmk
The creature spawn event runs as soon as you call spawnEntity
So, before the meta is applied
Use the version with a consumer to run stuff before it is spawned
What's the Consumer<T> function arg tho? 🤔
code that runs after teh thing is spawned, but before its placed in the world
ok so I'd set the meta there, right?
yes
nice ty
oh wait but how do I point the meta to the entity created if it is being created in that line of code? xd
thats what the consumer is for. use a lambda
mob -> { mob...}
ok so...
event.getEntityType() -> {setmeta} ?
no
😦
what's the first mob? lol
I undersstand that -> { set the meta } works like that
mob -> {
mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
}```
I just don't get the first mobthing
exactly a typed
the mob thing is the thing you are spawning. Its passed into the lambda as mob
yeah yeah nice
btw
do you know what the second arg in FixedMetadataValue is?
In the tutorial I followed it said it was an arbitrary value and I understood it doesn't matter but it kinda sounds useless to have a arg that "doesn't matter" lol
its whatever value you want it to be
if you read teh meta you get back a List of MetaData
from each you can read teh value you set
but isn't that the first arg in setMetadata()?
no, thats the key
yep
nice ty again (:
you just are not using the value
yeah pretty much xd
but it is not a "doesn't matter" value, that's what I wanted to clear so I don't write dumb stuff lol
yep, it could be anything, like a level of something
yeah
nice
hehe
oh wait 😦
Error:
The method spawn(Location, Class<T>, Consumer<T>) in the type World is not applicable for the arguments (Location, EntityType, Consumer<T>)
Code:
killer.getWorld().spawn(new Location(killer.getWorld(), center.getX() + offsetx[i],
center.getY(), center.getZ() + offsetz[i]), entity.getType(), mob -> {
mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));
});
what did I do wrong? lol
uhmmmm lemme see if I figure that out heh
killer.getWorld().spawn(new Location(killer.getWorld(), center.getX() + offsetx[i],
center.getY(), center.getZ() + offsetz[i]), entity.getType().getEntityClass(), mob -> {
mob.setMetadata("EL_Halloween_minion", new FixedMetadataValue(plugin, "EL_MD2"));});
Nice 😎
That's right... right? hahaha
oh wait I pasted my previous clipboard lol
there is a method on teh enum
there, edited
event.getType().getEntityClass()
yeah
^^
I edited it
I pasted my old clipboard before idk why my pc didn't get the Ctrl+C xd
I got it right now then (: ty
if(this.hasItemMeta()){ c_m = this.getItemMeta(); }else{ c_m = // there } c_m.getPersistentDataContainer().get(RunningMan.RM_ItemType, PersistentDataType.STRING);
how can I create a empty itemMeta
Itemfactory
yo I forgot hahaha
if World.spawn() "Creates a new entity at the given Location with the supplied function run before the entity is added to the world." then I'll have to manually spawn the entity? what would I use for that?
no, that method spawns it
Idk about your problem, sorry, but just for future help you should format your code in a code block like this:
```java
... Your code ...
```
oh okay so it's the same as World.spawnEntity but it does its function before the spawning and that's it? xd
yes
nice (: thanks once again hahaha
Is it possible to despawn / kill off a citizens api when the plugin stops? I can't work out how to do it 🤔
a big reccomendation to not use vscode for java
why?
move to something like intellij and you'll love it 10x more
100x easier, use eclipse if you have a lower end pc
ok, i'll try it
How do you check if the player inv is full, because when you add a item. it just doesn't work if the player has a full inv.
loop thru each item and find the first item that isn't air
boolean hasSpace(Inventory inv, ItemStack target) {
int amount = target.getAmount();
for (ItemStack i : inv.getStorageContents()) {
if (i == null) {
return true;
}
else if (i.isSimilar(target)) {
amount -= 64 - i.getAmount();
}
if (amount <= 0) {
return true;
}
}
return false;
}
nice, gonna update my relatively primitive function with that one
I imported my project and now I have this
did you setup a JDK
thank you
May I ask you which function should I use
I see,Thanks
ItemMeta
getItemMeta(Material material)
this?
tthe best part is that it wasnt even the issue
the issue was where he was trying to read messages.yml from
hm
anyone know who the dev is for grief defender is
i need to get the sponge version of it from him
message them on forums
on the spigot website you can message the dev
ye i did
Hi, the sponge version is available on discord. You should of received a discord invite via paypal. Check spam/junk folder if you do not see it. If it expired, send an email to kanesoftware@outlook.com and I'll send a new one.
someone asked exactly the same question on his profile
unable to compile compile/export correctly the plugin. It is pain, I do not understand nothing, I do not have enough experience with java
file is relative to the working environment. you need a static path
Isn't static? For example, in typescript relative is when I use "../../folder" and static is when I use "src/folder".
well yes its static just not in the right spot. you want to get the absolute path. its relative to the systems root, not the jar's dir
theres a method to get working dir, cant remember it though
oh, ok
hello i have a question
i want to make it so that when a player runs a command, it spawns an ArmourStand, adds the player as a passenger and slowly moves from point a to point b at an even rate with vectors
ive figured out everything apart from the vectors
any help appreciated
im new so if this is obvious then f
why use static?
Huh
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
^ something added the prefix to the display name
so whats the alternate method?
getName
huh?
thats kinda weird. i was tought that getName is CraftBukkit name
bunch of gibberish
alright
A user reported the following error by LibertyBans to me, telling them to tell me to relocate my dependencies.
Plugin 'SMPtweaks 1.0.13-beta' has shaded the library 'HikariCP' but did not relocate it. This may or may not pose problems. Contact the author of this plugin and tell them to relocate their dependencies. Unrelocated class detected was com.zaxxer.hikari.HikariConfig
Full error: https://www.spigotmc.org/threads/smptweaks.511138/page-2#post-4292496
From my googling, this means that two plugins are attempting to load the same class, causing a conflict, is that correct?
So I just gotta add a relocation like this?
<relocations>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>shaded.zaxxer.hikari</shadedPattern>
</relocation>
</relocations>
use the libraries entry in plugin.yml and you don't need to shade
^^^ should use that if you're making it for an api-version that supports it
How do I determine that I have joined the server for the first time?
oh thats much more elegant than what i was about to say
lol
was gonna say to check for existing playerdata files
if you type .has it will suggest you the right method
lmao
wait non of those
declaration: package: org.bukkit, interface: OfflinePlayer
@plush crescent p.hasPlayedBefore()
Thank you, that was very helpful. 🙏
np
is there a way to hide certain commands ie worldedit, so when a player does /<command> they wont see worldedit commands
don't think so
permissions?
not gonna hide them
worldedit does not obey permissions for commands.
o? dam
Hey I'd like to save HashMaps into a data file but what I tried doesn't seem to work...
Here are the code:
- PlayerData : https://pastebin.com/byf2nzUd
- PlayerManager : https://pastebin.com/s1hj7DwK
PlayerManager#loadHashis called when the server loads the plugin andPlayerManager#saveHashis called when the server unloads the plugin.
I also have an error...
I'm sorry, I'd like to make it a first time join decision for debugging purposes, is it ok if I delete usercache.json?
No, world/playerdata entry for their uuid
I see. Thank you very much.
Sorry, it doesn't work: ...... Am I doing something wrong?
(I'd like to determine if this is your first time here.)
It was a very rudimentary mistake: ..... I'm sorry, thank you very much.
why is no one helping me 😭
how can i check how many players are in surrival mode?
paste your saved data so we can confirm it has the correct data
I'm pretty sure it doesn't
then why are you trying to load any? Look at your error stacktrace
well when someone will install my plugin, they will start with no data
has anyone taught you how to read a stacktrace?
is there any way to set a default value? (to false for example?)
depending on how you are getting the data, yes
First off, yoru save hash and loadHash methods will not work
why?
uh i had a maven project
but i accidently pressed the debug button and now i can't get build and i get a long gradle build error
what can i do?
UUID is not serializable so bukkit will attempt to best guess its serialization as an object
and you can;t cast to a UUID, you have to use the static UUID methods to recreate it from a string
oh
so, getList is fine.
then you have to check its not null, then read each entry and create a UUID from it
probably somethign like UUID.fromString
https://pastebin.com/FDjAqgQU
(gradle build error)
stop your debug
i did
usually by pressing debug again, or (Eclipse will have a stop button in the debug log window)
Im using InteliJ
however i cant even press the debug now because of that error
I can;t help you with gradle nor InteliJ
like this ElgarL?
public void loadHash() {
List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
if (suuids == null) return;
for (String suuid : suuids) {
UUID uuid = UUID.fromString(suuid);
playerDataMap.put(uuid, playerDataMap.get(uuid));
}
}
cant i just use maven like the past?
Yes
is there a reason you switched from Maven to Gradle?
also it tells me (suuids == null will always be false so isn't it better if I put (suuids.isEmpty()) instead?
Did someone say gradle? 😄
nope there isnt i accidently pressed debug button and my project started gradle daemon
he clicked debug, now his gradle is fubar
uh well just terminate the debug instance you started running?
isn't initializing fields to null redundant?
i stopped debug mode but it isnt working ...
Should i try restarting the IDE?
And looking from above, you should have a settings.gradle in your rootproject folder
hm
Take this project for instance https://github.com/Conclure/Macrocosm
it depends, sometimes its just to shut the IDE up from bitching
settings.gradle.kts and build.gradle.kts
ah
.kts is optional
I wanna stop using gradle for now atleast but i cant and i cant even make a new build with gradle
What error does it prompt
As said
You need to have a settings.gradle in your root directory
Look at the link I sent
It’s a disaster to switch from gradle to maven but you’d have to delete all gradle related files, add a pom xml and restart and invalidate caches
im not sure which files are from gradle
everything containing gradle in it
But you’re not listening
There’s a much easier solution
Create a file called settings.gradle
Inside your project folder
but there is a problem...
there is no file that contains gradle!!!
ok
the /gradle directory, /.gradle directory, /settings.gradle and /build.gradle
delete those
And gradlew.bat, gradle.properties in case they’re present
That’s a different one
oh
why i cant send an image
use imgur
ok
or verify
oh i prefer verifying probably
!verify
Usage: !verify <forums username>
Oh okay
Just File -> Settings > Invalidate Caches -> Invalidate Caches and Restart or something
Then when it opens up again, import it as maven project
ElgarL is this method good now?
public void saveHash() {
List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
if (suuids.isEmpty()) return;
Set<UUID> uuidSet = playerDataMap.keySet();
for(UUID uuid : uuidSet) {
suuids.add(String.valueOf(uuid));
}
plugin.getConfig().set("playerDataMap", suuids);
plugin.saveConfig();
}
btw there is no Invalidate Caches
playerDataMap?
that's my string list
oh thats saving
public void saveHash() {
List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
if (suuids.isEmpty()) return;
Set<UUID> uuidSet = playerDataMap.keySet();
for(UUID uuid : uuidSet) {
suuids.add(String.valueOf(uuid));
}
plugin.getConfig().set("playerDataMap", suuids);
plugin.saveConfig();
}
public void loadHash() {
List<String> suuids = plugin.getConfig().getStringList("playerDataMap");
if (suuids.isEmpty()) return;
for (String suuid : suuids) {
UUID uuid = UUID.fromString(suuid);
playerDataMap.put(uuid, playerDataMap.get(uuid));
}
}
I'm also using it for loading
nvm found it thanks
create a List, then add each UUID.toString()
if I delete 2 first lines then what is suuids?
make a List<String>
ohhhh wasnt working
2:43:17 PM: Executing task ' --stacktrace'...
Starting Gradle Daemon...
Variable 'suuids' might not have been initialized
public void saveHash() {
List<String> suuids = new ArrayList<>();
Set<UUID> uuidSet = playerDataMap.keySet();
for(UUID uuid : uuidSet) {
suuids.add(uuid.toString());
}
plugin.getConfig().set("playerDataMap", suuids);
plugin.saveConfig();
}
yep
it wasnt working wtf
id rather name the method saveHashMap or saveMap
save hash can be misleading
what issue
yes, your error was nothing to do with your save/load
Cannot invoke "net.reikeb.maxicity.datas.PlayerData.setPlayerTeam(String)" because the return value of "java.util.HashMap.get(Object)" is null
WHich was when I asked you if anyone had taught you have to read a stacktrace
the next line tells you where the error is from
does Integer.parseInt of a coloured string works?
I never add the player's ID to playerDataMap
yep, there is no entry in the map for that player
try it and see
there is a strip color codes method
oh
I've already been told that but I must set a default value so what do I set as default value?
playerDataMap.put(p.getUniqueId(), new PlayerData());
or is it the actual bukkit one
is good?
uh just do getOrDefault(key, new PlayerData())
I'm adding player's UUID to playerDataMap because it was never added
does anyone know how i can make an animation with particles that looks like there are dots following the shape of a square? so like 4 dots in an outline of a square and each dot is like facing a different way, and then they all go forward until they hit a corner and then they turn by 90 degrees and repeat
something like this:
https://streamable.com/4ny3xm
oh and also without any entities or blocks or anything, just pure math
if you look closely, its actually just a square that is turned 45 degrees
to its side
with some rounded edges
huh?
i just put a rail track on a square and then added particles like 3 blocks above the minecarts to make an example
can u upload the video to imgur? for some reason streamable is blocked on my country
how can I make the time of each world different?I have no idea about it.
How can I change the font size of a message?
resource packs
there are also symbols that resize your message by a tiny bit but also make ur message look a bit weird/cool
Is there a page with all the symbols?
wdym
May I ask how to let different worlds have different times
Well, you mentioned that there are symbols that resize my message
well only by a tiny bit
hmmm
Then how those those plugins send message where the text is big?
For example
That’s just ChatColor.BOLD
ohh you mean bold
i don't think so, sorry
No worries ahaha
btw this is what i was talking about:
https://i.imgur.com/IbcjM9G.png
i was talking about the weird little lines in A and O but ok, have fun
May I ask how to let different worlds have different times
welp
in-game time or real-time or what?
that really depends
you didnt tell us all the information...
Isn’t time already per world
then just set the time in game by using /time set for every world 😂
set them different
maybe he accidentally somehow sync all the world's time
Other worlds will change into the same one as I use /time set
heh
idk bout that
so im just gonna disappear
I will think it over ,thanks
can anyone help me with my thing please?
i want to make this but with just math and stuff, no blocks or entites
I have an issue
It seems to forget things lol
My Minecraft has Alzheimer
Here are the files that handle the datas :
https://github.com/Max094Reikeb/MaxiCity/tree/master/src/net/reikeb/maxicity/datas
Nothing is written in config.yml
I would like to ask if there is a kind of item which can have no ItemMeta
Air
I'm trying to use SQLite with HikariCP, but I got an error, idk how to fix it.
Error: https://paste.md-5.net/fewepaconi.md
Code: https://paste.md-5.net/atumifozok.cpp
Issue with getting world from yml file.
issue with redis connection
Basic syntax problem?? I think??
- Downgrade Hikari version
will it affect the mysql part? because i used it too for the mysql
Im not sure
This is actually a "Bug" in spigot and vanilla: https://hub.spigotmc.org/jira/browse/SPIGOT-6496. You can change the time for a only specific world by using the api: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#setTime(long)
declaration: package: org.bukkit, interface: World
what version should i use?
3.4.5
what is the reason that i need to change the version?
The Bedwars1058 plugin also saw this issue. However, it seems to have been fixed by downgrading the library version.
ah well, i still got the error.
I'm not sure. Depends on the code.
Is my configuration for the sqlite database correct?
Someone correct me if I'm wrong but pretty sure SQLite doesnt need to be used with hikaricp
How to create a new key in YAML?
It's more for remote connections
Yeah you're correct, Hikari doesn't designed for SQLite I guess.
Since I use Hikari for the MySQL part, so why not use it for the SQLite too, but if it doesn't work then I'm gonna use the java jdbc.
It's not that it's not compatible, just that SQLite connections can be created much faster since it's local
Can you try this "?autoReconnect=true");
like this code ``` hikari.setJdbcUrl("jdbc:mysql://" + this.credentials.getHost() + ":" + this.credentials.getPort() + "/" + this.credentials.getDatabaseName() + "?autoReconnect=true");
So just use the java jdbc?
why doesnt Action.RIGHT_CLICK_AIR work?
Yeah
Alright thanks, but I have one question.
So before I'm using Hikari, I store the connection on a field everytime I'm opening a connection, and let the connection closes itself, and if the connection is still there i'll reuse it, is that the right thing to implement it with SQLite? Because you can only open one connection otherwise you'll get a SQLITE_BUSY error.
this is my code:
do cool stuff
}
You can reuse connections for SQLite yes
in PlayerInteractEvent?
kk
update: it needed if instead of else if
I have an issue
My Minecraft has Alzheimer
Here are the files that handle the datas :
https://github.com/Max094Reikeb/MaxiCity/tree/master/src/net/reikeb/maxicity/datas
Nothing else is written in config.yml
plz help
And in the command itself you also pass the value?
when comparing enums, yes.
thanks,I see
Alright
Time for Maow to reiterate the difference between reference and value comparisons.
== - reference comparison, this compares if the reference to an object is the same, AKA it's the same instance of a class.
equals - implemented per class, this compares if the values of the object are the same, AKA it contains the same data.
(reference comparisons are also known as identity comparisons)
The equals of an Enum will just check via identity comparison anyways, but it's better to use identity comparison since it's one less method call and it's cleaner to read an infix operator as opposed to a method call.
Enum constants will always be the same reference across the lifespan of the program, as they are static.
so pretty much there's not much of a difference
it's enum.equals(otherEnum) vs enum == otherEnum in terms of codestyle
Instance a == instance b if and only if instance a is instance b
ye
that's why you should use equals on Strings btw!
not doing so can lead to some strange errors
sometimes == may or may not work due to interning
Yuh value based class there
(also don't intern Strings via intern, use Guava's Interner, intern is very slow)
Uhh how i loop through a map and get take the biggest value and return the key and the value?
I dunno how you get the key
that includes info on String.intern btw ^
uhhh
could you rephrase that so it's easier to understand? @tardy delta
Yez
you'd probably have to store the key alongside max and then return it at the end of the method
so, basically
String key;
// ... loop - set key here ...
return key;
actually
better idea
you could just store the entry itself
since that would include the key and value anyways
making that one less assignment and one less local variable
Hmm yea
(and technically one less method call since you no longer have to call getKey on the entry to store the key)
then at the end of the method you can return entry.getKey()
Lieke this?
ye
But how do i give it a value without let that run every time so the max is gone?
So I'm working with a custom shapedrecipe rn how can I make one of the ingredients a poison potion
So if I have a list string, how can I combine into a regular string and have it say "Hello" instead of like "{"h","e","l","l","o"}"?
String.join("", iterable)
someone pls help
mmm yes one of the best fuckin' methods
Doesn't exist.
you're on java 8?
String join(String delim, List<String> list) {
StringBuilder builder = new StringBuilder();
ListIterator<String> it = list.listIterator();
while (it.hasNext()) {
builder.append(it.next());
if (it.hasNext()) {
builder.append(delim);
}
}
return builder.toString();
}
// No delim
String join(List<String> list) {
StringBuilder b = new StringBuilder();
for (String i : list) {
b.append(i);
}
return b.toString();
}
I don't think you really need a ListIterator there
it can be a normal iterator
or you could just not use an iterator
then you'd have to check for size and index
it's literally just if (i != size - 1)
cool points + 5
there's a small difference in performance bc of method call overhead and the object instantiation required for an iterator
🤦🏿♂️
and it's not even like you're going to be typing this over and over since it's a util method, so just like, use a for loop
iterator is universal, for can be used only on lists
that is backwards
I'm not referring to a for-each loop
and, for-each loops internally use an iterator
iterators are only available for objects that implement Iterable
maow
meanwhile for is just a basic loop statement
that has an init, condition, and step
you realize people get mad about you rambling on about the most minimal stuff
i prefer to ignore it
honestly this looks like that you wanna show your java knowledge if if noone asked
is there a way to set the name of a gui after creating it?
it's just useless to use an iterator for no reason :p
you could've just said: i would use the size solution for performance and the universitality of it
Make a new gui and set the contents
i wish there was an Inventory#setTitle method
then updateInventory would actually have a use
well ive been making the gui in the class construct so that there aren't multiple guis being created and then never deleted
yeah
last time i put the create gui thing inside my function, the events would end up stacking every time i created a new gui
I mean I did say that tho, just in more words
if I just said "for performance," then it would be unclear why it's more performant
I like to go in-depth bc it actually TEACHES people shit
It's just inventory inv = bukkit createinv bla bla bla and then inv = bukkit createinv with the new name
instead of just saying "oh ye this is slower, have a good day"
Inventory GUI = Bukkit.createInventory(null, 27, "Guilds"); yeah whenever i put this in the function, it stacks
gui
and yeah it's fun to flex the fact I know basically all of Java sometimes but that's not the primary reason I ramble
Theres also one without the holder iirc
I'm not even trying to be an asshole :p
ah ok
and like if this were exclusive to me, "bragging rights" wouldn't be a common term in the English language.
I might also be without the name 😔
Im trying to make a custom reconnect handler.
package xyz.fragbots.handlers
import net.md_5.bungee.api.ProxyServer
import net.md_5.bungee.api.ReconnectHandler
import net.md_5.bungee.api.chat.ComponentBuilder
import net.md_5.bungee.api.config.ServerInfo
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.event.PlayerDisconnectEvent
import net.md_5.bungee.api.event.PreLoginEvent
import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler
import xyz.fragbots.SandboxServerManager
import xyz.fragbots.player.ProxiedPlayerExtensions.isStaff
import xyz.fragbots.utils.ChatHelper
import xyz.fragbots.utils.Config
import java.util.*
import kotlin.collections.HashMap
class SandboxReconnectHandler(val main:SandboxServerManager) : ReconnectHandler, Listener {
val onlinePlayers = HashMap<UUID,ServerInfo>()
init {
ProxyServer.getInstance().reconnectHandler = this
}
override fun getServer(player: ProxiedPlayer): ServerInfo? {
if(!player.isStaff()&&Config.maintanence){
player.disconnect(ComponentBuilder(ChatHelper.format("&cServer is in maintanence mode!")).currentComponent)
return null
}
val server = main.serverHandler.getHub()
if(server==null){
player.disconnect(ComponentBuilder(ChatHelper.format("&cNo hubs online!")).currentComponent)
return null
}
onlinePlayers[player.uniqueId] = server
println("Player ${player.displayName} is being sent to hub: ${server.name}")
return server
}
override fun setServer(p0: ProxiedPlayer?) {
}
override fun save() {
}
override fun close() {
}
@EventHandler
fun onDisconnect(event: PlayerDisconnectEvent) {
onlinePlayers.remove(event.player.uniqueId)
}
}
But for some reason when a player gets disconnected in the get server it still shows their join and leave messages
prepare to get no support since nobody in here knows how to code in Kotlin
anyway you'd probably have to remove the messages yourself?
I've seen plugins that do that somehow
I mean it's more of knowing how bungeecords api works, and I'm wondering why the message is sending even though the player is never being sent to the server
Well are there any better proxy services.
Woah kotlin
How can i remove the join messages
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerJoinEvent.html
setJoinMessage(null)
declaration: package: org.bukkit.event.player, class: PlayerJoinEvent
Alright thanks 👍
Does anyone know how to connect minecraft to a discord bot?
Look up jda
Are you supposed to shade Adventure?
If you want spigot support I think you need to do that
Paper has adventure included
aight
it's just that it's a big library so I was wondering
like it adds 600kb to the output jar when shaded (api + platform) lmao
Yeah maybe just target Paper
no lol
[01:21:37 WARN]: **** FAILED TO BIND TO PORT!
[01:21:37 WARN]: The exception was: java.net.BindException: Address already in use
[01:21:37 WARN]: Perhaps a server is already running on that port?
``` anyone know why is this happening?
Or you could use the library loader feature
that makes it harder to ensure Spigot compat
there was something weird happening with my server, then i just delete the session.lock file in my world
that's meant to be used for non-Minecraft deps
then this happened
how would i shut that down?
Task Manager
Or just restart pc if you don't know how
(also I'm trying to support 1.14+, library loader is only available for 1.16-1.17 I believe)
Yeah shading is the only option then
You could use ProGuard with Gradle so minimize the jar as much as possible
it worked
Yeah
probs
Not sure if there are any good docs. I did get things running a couple of years ago worked very well
Idk if I still have the project
I assume I just messed up a configuration in my IntelliJ setup, can anyone help? Can't seem to access the NKMS packages, though they're in the files and not visibly causing errors
When I try to build, stuff such as this comes up: cannot access net.minecraft.core.Vector3f
Here's the dependency part of my pom
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Nevermind, was compiling with JDK 14 instead of 16, the errors seem to have gone away for now
anyone know why this is crashing my server with "timed out"? My goal is to spawn a circle-shaped particle effect around the player every 20 ticks if isEnabled is true
while(isEnabled==true){
Location location = player.getLocation();
double x = (radius * Math.sin(angle));
double z = (radius * Math.cos(angle));
angle += 0.1;
new BukkitRunnable() {
@Override
public void run() {
location.getWorld().spawnParticle(Particle.REDSTONE, location.getX()+x, location.getY(), location.getZ()+z, 0, 0, 1, 0);
}
}.runTaskLater(mainClass, 20); //FIXME
}
Infinite loop
true will be set to false eventually
also, u don't have to say
while(isEnabled==true)
u can just say
while(isEnabled
oh yea gotcha
Why don’t you instead create a Runnable that will cancel@itself until a condition is met instead of starting a new Runnable a lot of times while true
the repeating task runnable?
Aren’t you scheduling a task to run later every time The while loop runs?
the run later is supposed to be like a delay (every 20 ticks)
you should be able to schedule it to repeat
here's an example
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin plugin, new BukkitRunnable() {
int i = 0;
public void run() {
i++;
p.sendMessage("REPEAT MESSAGE");
if(i == 5) {
this.cancel();
}
}
}, 60L, 20L);
whats params are 60L 20L?
lemme look it up i forget
60 is seconds in a minute and 20 is the amount of ticks in a second J believe, I’m not too sure
L is for Long
60L is delay (in ticks) for when the first loop starts, and then 20L is how often it repeats (again in ticks)
From quickly looking online, is there any way to change a hopper's speed and amount of items, through code, and not via configurations? I'm wanting them to have specific speeds based on worlds
The only thing I can think of is making a whole event handler for it
Could it be something under hopper.getBlockData(), if it has a built in method?
just for further clarification, here's this
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin plugin, new BukkitRunnable() {
public void run() {
//do whatever
if(!isEnabled) {
this.cancel();
}
}
}, delay, repeatTimer); //Delay when starting first task, how oten it should repeat
When is isEnabled set to false? Is the condition ever met? If not jt might explain why the server is Timing out
Yes that’s way better
will this run async?
maybe this will help? i'm not sure https://www.spigotmc.org/threads/change-hopper-transfercooldown.279844/
it says it will be run on the Main thread