#help-development
1 messages · Page 1784 of 1
im using custommodeldata so it keeps the texture even if you rename it
md_5, do you know if its row & column?
uhu true
Thats NOT row and column. https://wiki.vg/Protocol#Set_Slot
Why cant you get the player on the leave event and remove the item?
could do that, but why add unnecessary events
i'd also have to consider player death event
just too much risk of duping imo
that still better than unecessarily using internals
what if the server crashes after giving them player the item
thats not your problem
cant change it back then can i
well it is
then he has an item he shouldnt have
its just too much risk of duping to give the actual item and not a fake
I mean crashes are still not a part of the system implementation since they're mostly unintentional and sometimes unpredictable
players can make a server crash intentionally
hence the adverb mostly
still something to consider
It's better to just trying to fix the crash exploit as well as saving frequent backups
Stop being paranoic and spend your time on something more useful rather than maintaining fuckery with packets for single feature
???
(s)he means me
if i now implement a dozen event handlers or a single nms call doesnt make much time difference
Its not paranoic, i've duped for years myself using server crashers etc., giving the player a real item is just simply an unsafe solution. imo.
but yeah, will stop discussing now
You may add a pdc Tag to the Map. On click, check if it has the tag. If yes, remove the item
yeah, thats a good idea
hey am still learning java here and
String prefix = Plugin.getConfig().getString("prefix");
return prefix;
}```
i did this
so that i can call it out on other classes
yeas
LoL
it didnt work
lol
String prefix = customChat.getprefix();
sender.sendMessage(prefix);
return true;
}```
it gives me error
isnt it supposed to give value of prefix from config ?
---> (customChat Plugin)
public static String getprefix(customChat Plugin){
you need to put CustomChat plugin in your method
the function definition of getprefix has what you call parameters
in this case 1 parameter
so when you use/call/invoke the function, you need to pass an actual value to the function
what is it on this case ?
your plugin instance
but I mean
technically if you want it simple:
String prefix = JavaPlugin.getPlugin(customChat.class).getConfig().getString("prefix")
and psst, customChat should be named CustomChat
yes i tried this and it worked
am just trying this out
alr
anyways it wants you to pass your plugin instance
or well to be more specific, it wants the object of your main class, customChat.java
and I'm using the instead of an as there can ever be one object of that particular class due to bukkit
i'm curious what was it?
idk but i changed the ingot to an iron ingot
and it still had no metas
it was diamond pick + my custom item (which was an IRON ingot) = normal netherite pick
Plugin plugin = customChat.getPlugin();
String prefix = plugin.getConfig().getString("prefix");
}```
this worked for me before ..
not now tho
lol
i forgot what i did for this
good
:D
I assume you understand variables decently?
Well next thing is methods
what do I have to be so my plugin actually saves and rewrites the values in the config?
(yes we're skipping loops, if and else stuff but I am sure you understand that somewhat more profoundly that the most hardcore oop concepts)
well
Plugin::saveConfig iirc
ok thanks, Ill try it
yeah
i know very well how to use if else statements
well lets skip it
yes
but in short its repetition (iteration)
yes i understand how it works
the foreach loop is the one I use the most. I could explain it really quick if you want
explain to me what a method is and give me an example
my item is crafting
i understand what this is :
}
ok 1 sec
but there is no meta still
A spigot plugin with only using enums
i'm just checking output right now before i send code
no
nice one 😄
?
scheduleSyncRepeatingTask gives back an int. In what range is this int expected to be?
Can it be 0? or negative?
thats task id
yea, thats what i assumed
what numbers can it be tho
cuz i wanna check if a task exists
so if i set default id to 0, and then scheduleSyncRepeatingTask returns 0, my check will not work
private int taskID = 0;
...
private void startScheduler() {
if (taskID != 0) return;
taskID = MapMenu.scheduler.scheduleSyncRepeatingTask(MapMenu.instance, () -> {
}, 0L, 1L);
}
see, thats why i gotta know what values scheduleSyncRepeatingTask returns
can it be negative, or 0, or is it guaranteed to be positive
pretty sure it only returns -1 if it fails
@EventHandler
void onPlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
PermissionAttachment pa = player.addAttachment(this);
for(PermissionAttachmentInfo painfo : player.getEffectivePermissions()){
System.out.println(painfo.getPermission()); //see if it's actually fetching the correct perms
pa.setPermission(painfo.getPermission(), false);
}
player.recalculatePermissions();
player.updateCommands();
So I'm trying to remove all default permissions from a player when they join so they can't use them or see them in /<tab>. It works for bukkit commands like /pl but it doesn't for default minecraft commands like /tell. They are definitely negated since I can't use them but they still show in tab complete. Is there something else I have to do to remove those from tab?
How to update my config in a bungeecord plugin? Like how do I add all the new sections that are created?
org.bukkit.event.inventory.PrepareSmithingEvent.getResult()
what is the right way to make sure the result isn't null
i want to catch it before i set name
am I changing the java home environment correctly? set JAVA_HOME=C:\Program Files\Java\%Input%
Meta will only be null on air
public class ItemHandler implements Listener {
@EventHandler
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
if (meta == null || meta.getLore() == null) {
return;
}
if (!event.getAction().toString().startsWith("RIGHT")) {
return;
}
if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
PlayerData.changeData(player, 1);
PlayerData.updateData(player);
} else {
meta.getDisplayName();
}
if (item.getAmount() == 1) {
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount()-1);
}
}
}
``` anyone know why this is repeating 2 times?
String prefix = Plugin.getConfig().getString("prefix");
return prefix;````
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage(customChat.getprefix());
}```
entire
import online.shakiz.CustomChat.customChat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class prefixtest implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage(customChat.getprefix());
}
}
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class customChat extends JavaPlugin {
@Override
public void onEnable() {
this.saveDefaultConfig();
this.getServer().getConsoleSender().sendMessage("§DCustomChat have been Loaded!");
}
@Override
public void onDisable(){
this.getServer().getConsoleSender().sendMessage("§DCustomChat have been Disabled!");
}
public static String getprefix(customChat Plugin){
String prefix = Plugin.getConfig().getString("prefix");
return prefix;
}
}
anyone know how to get rid of the "Unable to make field private" error?
I'd love the answer to be intellij, altho eclipse or netbeans also works
they are using intelliJ
intellij
Can you elaborate a bit?
ok
done
done
public static String getprefix(customChat Plugin){
String prefix = Plugin.getConfig().getString("prefix");
return prefix;
}
now do it for Plugin also
it should be named plugin notice the small letter p, not capital that is
heres the pastebin https://pastebin.com/B3dMEa90 but I'm using MongoDB as of current and whenever I leave the game and try to set my data that i've altered back into Mongo it gives that error. Which is weird because I've never had that error in any of my other projects where I use mongo
gives me error
getPrefix*
``` This is line 18
camel toe man
thats so confusing
yes was gonna get to that also
yuh lol
did it and it gave error on the getprefix class
send screenie
send more code
?paste
sender.sendMessage(CustomChat.getprefix(JavaPlugin.getPlugin()));
}```
on getPlugin()
yuh that works
tho its with the use of static 🤡
Zlaio can you send the entire stacktrace?
wait i'll try to fix
https://paste.md-5.net/oqozutimav.java All the classes used, Stacktrace: https://pastebin.com/B3dMEa90
the line its referring to is line 4 in the spigot paste
no worries
conclure is the best 
we still have constructors, static, more on types as well as objects
https://paste.md-5.net/lezeheneno.java is this what you mean?
@torn shuttle oh the issue was BLOCK_MARKER needs a BlockData so it cant be a drop in replacement?
is this the correct group id for buildtool? ```
<exclusion>
<artifactId>buildtools_1.17.1</artifactId>
<groupId>org.spigotmc</groupId>
</exclusion>
yes
but i have tests tmrw and gotta go now
thank you so much hf man
but if it was
It's in my maven repo
I put it in there
well then it depends what you put it in as
also becauseI want nms
the source code just does
can you try by putting a nullary constructor @winged anvil in PlayerData
nms != buildtools
nullary constructor = no arg constructor
I thought nms was in buildtools
that returned the same error
so then what is the point of build tools?
to make nms
hmm looks like there's an issue with gson
idk if lombok could cause any trouble as thats compile time but who knows
anyways Zlaio
you could create a custom type adapter
no idea its weird cause I have another project that does the same thing but it works
yuh
a custom type adapter
oh wait is it net.minecraft
class PlayerDataTypeAdapter extends TypeAdapter<PlayerData> {
@Override public PlayerData read(JsonReader in) {
//deserialization
}
@Override public void write(JsonWriter out, PlayerData value) {
//serialization
}
}
//then when creating gson use smtng like
static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(PlayerData.class,new PlayerDataTypeAdapter());
.build();
@winged anvil
mannn 💀 💀
ofc u have to do it manually now yeah
@EventHandler
public void PrepareSmithingEvent (PrepareSmithingEvent e){
if(e.getInventory().getRecipe() != null) {
CraftSmithingRecipe CRecipe = (CraftSmithingRecipe) e.getInventory().getRecipe();
if (CRecipe.getAddition() == null)return;
if (CRecipe.getBase() == null)return;
if (e.getResult() == null)return;
ItemStack First = CRecipe.getBase().getItemStack();
ItemStack Middle = CRecipe.getAddition().getItemStack();
ItemStack output = e.getResult();
ItemMeta MidleItemMeta = Middle.getItemMeta();
ItemMeta Meta = e.getResult().getItemMeta();
Bukkit.broadcastMessage("First " + First);
Bukkit.broadcastMessage("Middle " + MidleItemMeta.getDisplayName());
Bukkit.broadcastMessage("Output " + output);
Meta.setDisplayName("bob");
e.getResult().setItemMeta(Meta);
}
}
Middle Item Display returns nothing?
anyways zlaio, the problem is jigsaw
aka the java's module project
because it basically strongly encapsulate certain packages and their classes
internal Sun classes 😭
😔
anyways regarding this, I would say your plugin worked fine when used on another java version or smtng
wdym
maybe by upgrading gson, it could be solved
idk what my problem is
how would I do that
i get nothing from meta
you shade in a newer version of gson and relocate
if (Scrooge.isDead() == true)Bukkit.broadcastMessage("test"); why doesn't this work...?
is Scrooge a class?
scrooge isan entity
a variable?
Also why == true
if (cmd.getName().equalsIgnoreCase("start")) {
Entity Scrooge = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 33 ,-181 ),EntityType.VINDICATOR);
Entity Pet = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 33 ,-181 ),EntityType.PHANTOM);
Entity Lightning2 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),-5, 67 ,-153 ),EntityType.LIGHTNING);
Entity Lightning3 = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"),4, 67, -153 ),EntityType.LIGHTNING);
Scrooge.setGlowing(true);
Scrooge.setCustomName(ChatColor.RED + "Scrooge");
Scrooge.setCustomNameVisible(true);
Pet.setCustomName(ChatColor.GOLD + "Scrooges Pet");
Pet.addPassenger(Scrooge);
Pet.setCustomNameVisible(true);
if (Scrooge.isDead() == true)Bukkit.broadcastMessage("test");
```
boolean
true just do Scrooge.isDead()
Well duh
rename Scrooge to scrooge, rename Pet to pet, rename Lightning2 to lightning2 and rename Lightning3 to lightning3
You can remove == true and it will work
it causes a lot of confusion
It didn't i've tried.
camelCasing
Then you've done something wrong
thing is
it will almost never be false
because you're literally spawning that entity right there
then just some code later are you checking if its dead
like precisely after the entity was created
also conclure is shading just adding a gson dependency into my pom
no, you're doing that but yeah
that'd be whats needed
@foggy estuary
try !scrooge.isDead()
oki
which will work
Oh i see what you mean by false.
👍
!IsDead() offset so alive
I never said it would fix your issue. Removing == true changes nothing about the behaviour you're just removing redundant code
Makes sense.
oof
might wanna try moshi then
since its hella similar to gson
but much more modern
And for some reason using annotations instead regular polymorphism
which is quite nice
Bukkit.broadcastMessage("test");
}``` am i stupid? if i kill the entity it should broadcast "test" yeah?
That's why it isn't working the way i wanted,..
probably lol
are you tryign to serialize/deserialize an inventory to Gson?
no
do arrays serialize ?
not lists but actual arrays cause I am using arrays in my Group object
Hey, I don't know if anyone has experience with the worldedit api but I'm trying to work out how to check the blocks x blocks away from a current cuboid region are a certain type and if they are then do stuff I currently have https://gist.github.com/UntouchedOdin0/75ec899fdea33d52bd033076229ddb0d but no luck upon how to expand from there
ItemStack?
no Player[]
um, why?
the group is made up of players but i might just store their UUID
I think that actually causes problem
Yes, you can;t recreate a Player object so its pointless trying to store Players
Your error is because Gson will be unable to create teh Player object
Thats the reflection error you are seeing
It will also happen with ItemStack metaData
I got the same error, does this look right? https://paste.md-5.net/jutojocimu.java
UUIDs are going to be difficult, straight to Gson too. The object need a constructor
so string
Constructor to create
well
Player creator ☹️
I believe gson actually registers a uuid type adapter
wdym by this
well the only problem should be Player
Gson uses an object no args constructor to instance any object. Then it uses reflection to fill in its fields
its not required tho
yuh, to be more exact, gson uses unsafe to instantiate the instance of the type, at least it used to do
yeah that was the problem, storing players I forgot to change my Player creator lol thank you
for(byte i = 0; i >= 0; i++)
Why does Intellij say Condition 'i >= 0' is always 'true' ?
Does this work for anyone else I can't seem to import their library ```
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.3.0</version>
<scope>provided</scope>
</dependency>
because i is always greater than or equal to 0
I mean
its not
because starts with 0 and just increases after that
never goes below 0
but Java is working with it arithmetically
You know why 127 + 1 = -128 bitwise?
yeah
well, that only happens bitwise, arithmetically this statement is totally false lol
show it to your math teacher and he will slap you
well yeah, but numbers are just bits
yeah, but you're working with them arithmetically
byte a = 127;
a++;
System.out.println(a);
prints -128
oh, I didn't know that was possible in java
xD
i assume Intellij just doesnt know im expecting it
and therefore warns me (wrongly)
right?
yeah
++ = - algebra math
I don't like that way to avoid the Numeric overflow tho
well, how can i loop over every byte from 0 to (including) 127?
a = a +1;
this surprisingly works good
I get warned by:
xD
"billion times" yeah...
they should change that text for byte and short loops
as I say, it's pretty counterintuitive
:D
Byte.MAX_VALUE is a thing
it's weirder, BARRIER particle used to be the particle for the BARRIER block when placed, BLOCK_MARKER is the particle for the barrier block item when dropped best I can tell
Anyone know why Fastutil is not wanting to import? (Using maven)
at least that's what fits size-wise
it's exactly the size of a dropped barrier block and no longer the size of a barrier effect when placed and viewed while holding a barrier
"external" lib
Also I did try the BlockData as shown by Choco and it did not work, or at least I couldn't make it work using the method he showed
how does namemc get it
mojang api I believe
alr ty
GodCipher can you test something for me?
what exactly?
I need you to add something your pom.xml and see if it works
I'm not sure if it's on my end so I need someone else
Now I'm confused
a timestamp
how do i convert it to readable time
not really.
google is your best friend
nvm, forgot they don't use the negative bit ;p
So you won't test it for me 😦
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.2.2</version>
</dependency>
works for me
does spigot support changing the price of combining items in an anvil?
help pls
invalidate caches and try again
why is this not using &c?
config.addDefault("DamageIndicatorHologram", "&c %damage_message%");
look at your code
?
translate
i have used that in other plugins and worked
then you did the right code in the other plugins
from the looks of it, looks like it doesn't
I'm not in deep enough to know
I'll see if I can find out, is there a resource that makes figuring that out easier?
can you try AnvilInventory#setRepairCost
it might work
(event.getInventory.setRepairCost)
emphasis on might lol
interacting with things like that in prepare events is tricky
I'll test it and let you know what happens
I still have nightmares from trying to work with one of the grindstone events
cant you just use a crafting table
would be really good if i wasnt making a auto crafter
if not, its going to be a fair few lines of code
whats the method for parsing a text as it's material value
the vanilla crafting system is hundreds of lines
could you send it? 😳
Material or block?
item material
wdym
for guis
a
Material.matchMaterial
awesome thanks
you can decompile the server yourself
yes but i would like to know where is the code
i got it 😄
you couldnt just copy paste it anyway
Im using eclipse and on my plugin and config.yml files there are question marks, does anyone know why this is? Its the first time I see this.
what question marks?
i just want the idea for now
the code would be awesome too, but i really want is the idea
ShapedRecipe / AutoRecipeStackManager
as you can see its very complicated
though its mojang, so probably overcomplicated
if(e.getInventory().getRecipe() != null) {
SmithingRecipe CRecipe = (SmithingRecipe) e.getInventory().getRecipe();
CRecipe.getAddition().getItemStack().getDisplayName() it gives me nothing
}
you could definitely do it much simpler
is it better creating info in the config.yml like this or doing it manually?
Option is yours
I'd rather make a file and just save it, but if you would rather write those defaults in source, go for it
I cant send an image
verify then
you mean creating them like this?
If you're seeing question marks in your editor, you probably have a lower source encoding than is used in the file itself, J4KOB
lol
Just means Git hasn't tracked it 😛
by the way, to write notes in the config yml, how is it suposed to be?
#comment
python cool
this?
yes
ty
Why are there question marks on my yml files? https://gyazo.com/331cbe249070f81279a63e19d30c1cc4
you were answered....
yeah - it’s git not tracking them
ohh
Can either disregard, or if you intend on using git you can track and commit them
wut i'm doing wrong ... getDisplayName() returns nothing
Can I publish plugin extending premium plugin API when it loads even without it?
I post in development because it's related to developing.
@austere cove
as per the guidelines
(premium) Resources must not depend on other premium resources.
afaik you are allowed to publish it aslong as you dont have to pay for it
Can I do the same?
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
``` this is the correct one to create nms correct?
yes
reload:
message:
- "&cDamageIndicator reloaded!"
#- "You can add more lines too!"
CancellingCrits: false #Default in false, i'll recommend you to leave this in false except you have a custom crit plugin
enablingHolograms: true #Enable and disable holograms when you hit entities
DecimalsAboveOne: '#' #If your damage is more than 1 it will give a number without decimals if you want to give more decimals add a .## (You don't have to add # to give more than 1 number like 30)
DecimalsUnderOne: '#.#' #the same as above but with less than 1 damage.
DamageIndicatorHologram: "&c %damage_message%" #The message it appears when you hit an entity %damage_message% is the damage variable IMPORTANT will only work here.```
I have it like this but in the plugin folder config it doesn't appear
so making a free plugin depending on a premium one is legit, but making a premium one depending on any other plugin is not
the #text thing
resource staff will most likely approve prem resources soft depending on a prem resource as long as the main functionality of the plugin keeps working
but I'm not resource staff so idk ¯_(ツ)_/¯
Main functionality of aacaditions pro doesn't work without aac
Should I ping optic or should I wait for answer?
its from 2016, unlikely the rule existed then
^ that
some help with this? pls 😄 the # text doesn't appear in the config.yml at plugins folder
itll only appear if you use copyResource and dont save over it
api doesnt support comments yet
U enforce rules backwards so that's not an argument
copyResource?
saveResource idk
The 20$ thing was enforced backwards too
look in the JavaPlugin methods
no it wasnt
most rules like that are not backwards enforced
yes
i'm tryna pass an object as a parameter in an interface implemented method, but broadcasting it shows 2 different instances
like passing it was creating a new instance of the object
so i decided to create a fake crafting table for my auto crafter
basically i have some items somewhere and i want to place them in my auto crafter
in all possibilities possible
and check if that matches the recipe shape
how could i do that
?paste
i fixed it myself Smithing
e.getInventory().getItem(1).getItemMeta().getDisplayName()
also it return nothing if the wasn't renamed
https://paste.md-5.net/umudohimud.java does anyone know how to make it work? so that the effects only work at that one block location
player11 is in red and i cant figure out what to add to make it not
Well you haven’t declared player11 anywhere
You can’t just pull a player out of nowhere
e.getPlayer().getLocation();
check for the specific location
if player is at that location give Effect and then remove if they're not in that location
@foggy estuary
Check for distance
yes
Being at an exact location is very hard
like x y z
distanceSquared already exists
So does distance, but that is slower
hmmm
does this seem alright then..?
public void blockBreak(BlockBreakEvent event) {
{
Player player11 = event.getPlayer();
Block blockloc = player11.getWorld().getBlockAt(-2, 66, -153);
Material material = blockloc.getType();
Player player1 = event.getPlayer();
if(material.equals(Material.GOLD_BLOCK))
Bukkit.broadcastMessage(ChatColor.GOLD + "YevTheDev is the thief!");
if(material.equals(Material.GOLD_BLOCK))
player1.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 40000, 10000));
if(material.equals(Material.GOLD_BLOCK))
player1.playSound(player1.getLocation(), Sound.BLOCK_BEACON_POWER_SELECT, 2F, 1F);
}
}
}```
always use distanceSquared if you don't really need the exact distance
wait what about if(Location = e.getPlayer().getLocation())?
@young knoll
i need to check
what about it?
it works
if that works
.equals
And like I said, two locations will almost never match
equals is better for string?
is that a real question?
equals compares object's properties, == compares whether it's actually the "same" object
Memory reference to be specific
yep
Used for primitives and enums mostly
yeah i know why the yaw
if that is to be correct
rule of thumbs: if you're not sure on what to use, use equals
"quite" = "extremely" ^^
Location(World world, double x, double y, double z, float yaw, float pitch)
what are you trying to achieve?
Especially because equals() defaults to == :P
erm no not really
almost every object has its own equals method
what the differences guys?
class*
Hence *defaults to
imagine this
Object#equals()
you have a class called Person
class Person {
String name;
public Person(String name) {
this.name=name;
}
}```
you can now do this:
Person person1 = new Person("mfnalex");
Person person2 = new Person("mfnalex");
person1 != person2 but person1.equals(person2) will be true
(If it has an equals() method that compares the names)
Well it would if you overrode .equals
as said
person1 != person2 vs person1.equals(person2)?

== simply compares whether both objects are exactly THE SAME object
while MOST of the time, most objects have an "equals" method
and that method doesn't check whether both objects are exactly the SAME object, but whether all the properties of that objects are the same
you know what I mean? ^^
it's hard for me to explain
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
memory stuff?
I will make a simple real life comparison
imagine you have your school testimony
now you put it into your printer and print a copy
they will be equal, but they won't be ==
it's two different documents with same content
i could still use help with this
so they are equals() but they aren't ==
if anyone's up for it
String s1 = "HELLO";
String s2 = "HELLO";
String s3 = new String("HELLO");
System.out.println(s1 == s2); // true
System.out.println(s1 == s3); // false
System.out.println(s1.equals(s2)); // true
System.out.println(s1.equals(s3)); // true
true
false
true
true
that's very specific
it was in your link
first comparison will be true although they technically aren't but that's just because the JVM caches Strings
pls ignore Strings for a second
they equals the same but arent 100% the same right?
yes normally that's true
object1 == object2 does this: "Yo, Java, does both, object1 and object2 refer to the same RAM address?"
oh man I have an issue with equal strings but now I don't want to post it 😆
well basically
if and only if a == b then a must be b
Another rule of thumbs: for Strings, ALWAYS ALWAYS ALWAYS use equals() unless you REALLY REALLY know what you're doing
strings are a bit of a special case in terms of == and equals
you should ALWAYS use "equals" unless you expicitly know the difference between equals and == and know what you're doing
I am comparing 2 strings that are both printing to the same thing in console, but when I compare with .equals it comes out that they are different 🤔
then they are indeed different
try to print them out
System.out.println
check it out, there MUST be a difference
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message){
if (channel.equals("minecraft:brand")){
String brand = new String(message);
System.out.println(player.getName() + " is connecting with: " + brand);
if (!brand.equals("vanilla")){
System.out.println("not vanilla!");
} else{
System.out.println("vanilla!");
}
}
}
Console is printing not vanilla
Does brand have trailing spaces or something
I tried stripping unless I did something wrong
add System.out.println(channel) and see what it shows
oh sorry
I meant
System.out.println(brand)
ah ok
I mean they are
Print it with characters on each side to show it there are any leading or trailing spaces
yuh or use smtng like hashCode which if they are unequal in terms of hash, then they'd have totally different hashCodes
pls copy paste the output
[MEME] suffocated debugger exists but System out print
there's probably some invisible characters inside the output then
[17:16:57] [Server thread/INFO]: vanilla
[17:16:57] [Server thread/INFO]: Not vanilla!
like that?
pls someone i can't continue
You can decompile the output jar
Or go into the folders generated by buildtools and look at the source there
what?
What?
what am i supposed to do?
I just told you
Decompile the output jar or look at the source in the various folders
idk what that means
ok so this is so weird...
public void blockBreak(BlockBreakEvent event) {
{
Player player11 = event.getPlayer();
Block blockloc = player11.getWorld().getBlockAt(0, 24, -266);
Material material = blockloc.getType();
if(material.equals(Material.GOLD_BLOCK))
Bukkit.broadcastMessage(ChatColor.GOLD + "YevTheDev is the thief!");
if(material.equals(Material.GOLD_BLOCK))
player11.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 40000, 10000));
if(material.equals(Material.GOLD_BLOCK))
player11.playSound(player11.getLocation(), Sound.BLOCK_BEACON_POWER_SELECT, 2F, 1F);
}
}
}```
idk why but whenever i break a block now, it gives me the yevthedev is the thief ect
yes
Also also you don’t need to repeat the same if condition 3 times
Strange things
Oh lemme guess that was probably the if check
And player11 is a weird variable name
he started
im stupid and just copy pasted my old code and put in this and wondered why it werent working
yeah....
pro coders be like
player1
player2
player3
player4
player5
😂
ironic joke
^
player_1
Anyway ! how it going with the code
How could I calculate a players horizontal friction?
you asking me.?
yeah!
my server crashed so ill have to check in a sec lol
im still getting bullied by a string comparison, fun stuff!
hm...
ok
i have no clue now...
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block blockloc = player.getWorld().getBlockAt(0, 24, -266);
Material material = blockloc.getType();
if(material.equals(Material.GOLD_BLOCK)) {
Bukkit.broadcastMessage(ChatColor.GOLD + "YevTheDev is the thief!");
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 40000, 10000));
player.playSound(player.getLocation(), Sound.BLOCK_BEACON_POWER_SELECT, 2F, 1F);
}
}
}
still when i break any block it gives me this
get block from BlockBreakEvent
check if it is equals that specific location for the gold block
wdym
it should just say, "hey i see ur breaking that gold block at that specific location... ima give u the perks now"
instead of giving me perks at any block i destroy
Yeah
But you are constantly checking if a gold block is at that location
So unless you break it, it’ll always be true
Like
if(Player.getName().equals("Joe")){
it will do Stuff for joe
}
dont use this operator to compare strings
how do i specify an api version :_)
api-version: in plugin.yml
oh ok
@ivory sleet btw I just checked and the hashcodes for my 2 string are completely different, no idea how :/
Location loc = new Location(Bukkit.getWorld("World"),0,70,0);
if(loc.distanceSquared(e.getBlock().getLocation()) == 0) {
Bukkit.broadcastMessage("You Broke at the Right place" + loc.distanceSquared(e.getBlock().getLocation()));
} else {
Bukkit.broadcastMessage("You Broke at the Wrong place" + loc.distanceSquared(e.getBlock().getLocation()));
}
if your strings are different, the hashcode is most likely too
but for what do you need the hashcode
so it says it cant find it but it exists .....
I have 2 strings that are printing the exact same but .equals says they are different, they said to check the hash codes to see if they are different
@foggy estuary
oh shit
thank you im off my pc now but i can try that tomorrow
i appreciate it !
no problem
i just ran the code 
so no problem there
@foggy estuary you can kinda thank @young knoll for making it so simple
lemme test it 🙂
for what should you check the hashcode? do you have an example of the strings and your check?
i dont see whats wrong
@hybrid spoke #help-development message
ok thanks!
your package is dwaapl, you are looking for dwaaple
whats the output when printing your brand
branded printed vanilla, the if/else printed not vanilla
if you scroll down a bit from the code I posted the output and such
is there a better way to test plugins than stopping a server, resetting it, then starting it back up again?
you can test your model with JUnit but other than that not really
damn, that sucks
mockbukkit
technically not spigot
but it has some mocks to emulate the most necessary things
believe minidigger also has some thing for acceptance test or if it was integration tests
[18:13:32] [Server thread/INFO]: brand length: 8
[18:13:32] [Server thread/INFO]: vanilla string length: 7
@hybrid spoke I think you may be onto something
exactly
your string takes the length of the byte array
trim the string, that will fix it
Oh I stripped it, that must be different
Yeah I'm like 1 day into Java lol
Yep that fixed it! Thank you so much 😁
wait so it was extra whitespace then?
more or less, yeah
your string took the length of the entire byte array and used to be "vanilla\0" or smth but the \0 gets vanished when printed out. trim() considers \0 as a whitespace
oh interesting, yeah I guess that makes sense considering the message.length is also 8
appreciate the help!
https://stackoverflow.com/questions/12730007/java-string-constructed-from-byte-array-has-bad-length maybe a better explanation
a bit above my head but I think I get the basics
While I have you here you wouldn't happen to know why default minecraft commands aren't removed from my tab completion list even though I'm negating the perms for them would you? 🤔
Anyone know what buffer is used for?
its basically a block of memory
that you can write data in
and read later on
for example, channels use buffers
take a look at this https://github.com/GladUrBad/Medusa/blob/master/Impl/src/main/java/com/gladurbad/medusa/check/Check.java I'm trying to figure out what is buffer used for
no, because that clearly isnt a proper name
a buffer is a block memory which is wrote onto/read
that is the universal meaning
i still need help with this btw, if anyone can help
do you need to use nms?
y tho
you will kys
sheeesh
Is it true you can make your plugin support plugins below 1.17.1 without nms?
I know that there is Reflection but that's poop
but then you are make a new class everytime for each version
Methods can only be used on 1.17.1 and 1.17
Are you referring to server internals?
mhm
Oh, then why did you say "without NMS"? lol
Yeah, your option is either reflection, abstraction (class for each version), or use Bukkit API
I would advise for the second (well third but yk)
No fourth option?
Magic
hm
I was making mobs with Armor and when testing them they release their armor, how can I make that not happen?
What's the most efficient way to read/write an ItemStack object through locally stored data?
Best to just use yamlconfig
does anyone have a good tutorial on nms?
b r u h
what
no lmfao, nms has no documentation at all
the best you get is wiki.vg
thats why you should avoid it if you can use api
what even are you doing?
you shouldn't "learn" NMS
you only use it when you need it
all i know is that nms can be used to do things that the spigot api does not have, and therefore i want to learn how to use it
like for example rn i want to make a custom head itemstack, but for that there's a method from a forums thread that uses gameprofile, and idk what gameprofile is and the method doesn't work for me
nms stands for net minecraft server
then use
its 1 class
i wanna be able to make it by myself, without using other people's code
do you know what i need to learn in order to make that?
you cant
well if someone did it then obviously i can
im sorry, but getting heads is something id just not want to deal with myself
just use someone else's working code
i don't like using other people's code
i can't
you are using spigot api
that is someone else's code
lol
and also base64 is a very common topic
in computer science
like super super common lol
nobodys going to help you learn NMS
cause nobody has tutorials on it really
its like the dark matter of space
you can stop now
No one wants that headache
exactly
im telling you why nobodys going to help you man...
you gotta change up your question
this is like the third time you said "no, you can't do that"
When you find something specific you want to do that the API does not cover, come back and ask..
custom heads, as i've said
i have said that i don't want to use other people's code, right? did i just dream it?
i'm just gonna ignore you from now on
I'm new to plugin creation and I'm working on creating a ChatColor plugin however when I type /chatcolor the GUI doesn't open.
Can someone look at my code and help me fix it?
fine, but thats not gonna do you any good tbh
space you should use technovision's tutorial on custom inventories
listen to us and elgar
???
please
Technovision is absolutely bad
bad coding conventions
Dont listen to him
Please
I'm just looking for someone to look at my code and tell me what I'm missing
?paste some code @quaint mantle
pulse i have not heared a single positive thing from you in the past 10 mins that we've been talking
and i have no reason to be
This is my first week so if I'm missing something crucial I hope you understand haha
if you want people to like you, then you should be positive
dude, ive been in this discord wayyy longer than you. ive seen too many people like u b4 xD
stop acting like im going to give a fuck
teh command you seem to be listening for is changecolor
What happens when you run the command @paper viper ?
yeah i'm just gonna go back to ignoring you, you clearly do not want to be nice
o.. I thought I set the aliases as /chatcolor
Thanks haha that was easy
Why would you think you set aliases?
can anyone help me with making my own code for custom heads?
?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!
oh wait
I'm dumb
I put the command as chatcolor not changecolor
did u accidently ping me xD
Whoops, looks like I did, my bad
All good
i tried to import it, but it didn't work
https://paste.md-5.net/susagamahi.xml
Whats the difference between the PlayerJoinEvent and the PlayerLoginEvent
And which one should I use when making a ban plugin
oh that's neat
If you can't use an async one, use login
disallow() and allow()
mhm
why would i want to help you after what you said...
also did you even add the repo
i just used the class, forget it
He did, he needs to refresh his maven or invalidate caches
he copied the class over instead 💀
oh 😦
How do I get the player event.getPlayer() doesn't work with it
ok i refreshed maven and it works now, thanks
there is no player in teh pre login event
Or IP, which you can also get
at the same time im also kicking the player
You can just disallow
god damn im slow
is anyone comfortable with libs disguise api?
hey does somone have experience with bedrock texturepacks I want to set a custom texture when an item hits a specific durability
@young knoll sorry to bother you but I can't find anything on what I would use for the leaving part
mind helping me out rq?
Leaving part?
Yeah im currently using PlayerKickEvent which is probably what I shouldn't be using
Mainly im just trying to remove the Player has left the game
so apparently it's for fixing false positives for checks
Bruh tf
why would they call it "buffer"
no clue
it should be more like error something you know
like you know in science
when you collect evidence
you have to account for possible margin of error
it should be called that
it also means something to absorb impact
its also something in bio i think
like you know ph buffers