#help-archived
1 messages ยท Page 217 of 1
alright
SO now there is always one instance of the calss
unless someone manually creates a new instance.
The static way I showed always creates the instance the first time the class is accessed either way both works
How you choose to do it is up to you
But its always better to prevent access to the Field
how do I get the class instance?
Just copy this and rename Class1 to your class name
private static Class1 _instance;
public static Class1 getInstance() {
if(_instance == null)
_instance = new Class1();
return _instance;
}
the new Class1() line creates a new instance object of the class and sets it to the private instance field
^^
The null check makes sure it wont create a new instance everytime the static method is getting called
oh and make the constructor
private Class1() {}
This way no one can create a new instance
it doesnt require to have a constructor
That just makes the constructor private
You can create new instances without having a constructor
It will stop users from using new Class1() outside of the Class1 class
Yeah thats true
yus
Now do whatever you'd like. Let's say add those constructor values you wanted in to the private constructor
@formal nimbus The reason why the field is private is because if there is allot a data being stored in the class people cant reset the instance.
ok so that means I can make those things not static
since I'll only ever have 1 instanceo f the class anyway
lombok?
It's an utility that adds annotations such as @Getter and it will generate getters for you
o
It's quite convenient when you have a lot of getters and setters
^
@formal nimbus TIP: Use as less static members as possible
If you're working with interfaces you can use dependency injection
dependency injection?
Because static members should only be used when needed
^
otherwise your program can become filthy
lmao ok
I forgot how to explain it in englishKEK
we have a code purist over here
There are certain cases when you need static but usually you don't need them very often
Its preffered to only use static members for Utily/Helper classes
I have a list of objects which I want other plugins to be able to use
And ofcourse when you're working with Singletons
how do i do that?
Make a getter for it
^
People should never be able to directly access the fields
so they'll be able to use the public getter?
Yes
since they are major to your code
k cool
If they can get the instance of the class they can use a public method
^
how would they get an instance of my class?
with the getInstance method
^
When its called for the first time it creates a new instance of the class and sets it to the private field
heh
This makes sure there is always a single instance floating around
aight
Which means: Less memory usage = faster and responsive code
but how do you set it up so the 2 plugins cace?n interact in the first pla
You mean when 2 plugins call it at the same time?
how would somebody else make my classes become visable to their IDE?
You add the first plugin as a dependency
ah
How you do that is up to you
ok, so like you do with spigot API
Yes
let me create a example for you
sure
With some explenation about what it does
it's annoying, every day I find some new thing I've been doing wrong with my code xD
but on the plus side I guess it means I'm learning
I've been programming in C# for 4 years and still learning everyday
When you know C#, java is childs play
i need some help im getting a error for my plugin cn anyone help me
They're very close
i cant send pictures idk why can i dm them to u?
Sure go ahead
@mellow wave Dumb question. How to create a summary about a member?
in C# you can like /// <summary>
They're very close
@mellow wave nice ๐ฎ
Dumb question tho ๐
I guess learning C# should be no problem then
I guess it's similar to learning languages
natural ones I mean
except coding languages will be even more similar, just with different syntax
Syntax
?
? ?
constant variables should be UPERCASE
o
So other people know they are constants
I haven't been following that scheme
It's naming conventions
You can find them if you look them up
Naming conventions is not a mandetory thing to do
right
^
but recommended when working with API's
well maybe in my next project I'll use it
for now though I'll just stick to using camel case for everything
For starters its better to learn what the acces modifiers are
and what the diffrences are
yus, I think I've at least got that down lool
I find it infuriating how you can't change the name of a GUI after it's creation
*an inventory
would make life easier ):
public class DataManager {
//This field holds the singleton of the class. The reason its private is because we dont want people to create a second instance.
private static DataManager _instance;
//Holds a collection of names. The reason that its private is because we dont want people to directly access it.
private final List<String> _names = new ArrayList<String>();
private DataManager() {}
public static DataManager getInstance() {
if(_instance == null)
return _instance = new DataManager();
return _instance;
}
public List<String> getNames() {
return _names;
}
So lets say you have a data manager class that stores data
That means you dont want to have multiple instances floating around.
The perpose of the singleton is to ensure there is always a single instance.
uh huh
For example. in this sample you see a List of names right?
Well if people constantly create new instances the names collection will never be the same
yep
Because we dont want people to access the field directly
or if you had a constant, you would end up with duplicates of the exact same thing
because then they can screw up the behaviour and the data
yee
for something like this
it's an ItemStack factory (I think?)
anyway it's a helper method
can I just make it static?
Factories basically provide a easier way of creating instances
right, so it is a factory then
Your createItem method should be static
with a lot of helper methods
I could make the class static
as long as it doesn't store any data
Creating a static class means its members can only be static
Everything inside a class are defined as members
See a class as a blueprint
they store data
For examplle you have a person class that stores the Name, Age and Gender of the person
Its basically a blueprint of a person
Uuh lets see. In C# this works so....
๐
I never really got into java
its different in some aspects.
As i see, java doesnt support static classes
But its not a big problem since you can create static methods only
yep
After you got the understanding of how classes work, go try to refactor your code
Like create certian fields readonly
Thats why in my code example the names list is marked as final
So java knows it will never be re-instantiated
Which results in saving -up memory
Which corresponds to a faster plugin.
yus
I've already been trying to make all the variable which I can final
can I make an ArrayList final?
I mean it changes in size
@wispy pewter
yes it can
o
final aka readonly means it can only be instantiated one time
if you want to know better info call me
I can explain better in call.
Call me if you can or want
can someone help me i got an error in
plugin.getConfig().getString
I will give a proper explenation of a factory's work
and why and when you should use private and final
@twin cosmos The plugin variable is only available in the main class of the plugin
Make a instance of the main class
and call it trough there
what materials cant be used for crafting?
...
because for some reason whenever i try to use Iron Ingots in a crafting recipe the recpie no longer exists
Call me if you can or want
@wispy pewter I appreciate the offer, but I can't do a call atm
though I might be able to at a later point
That's fine.
Is there a spigot API
Yes
To check if a user has brought a plugin
oh no I got warned again -.-
You mean checking if an plugin is loaded?
Buyers check
Ye
Look at MVdW example
Is there like an API json
what materials cant be used for crafting? because for some reason whenever i try to use Iron Ingots in a crafting recipe the recpie no longer exists
There is a JSON API
I have crafting.powerdirt set to false but I can still craft the powerdirt. Can anyone catch why?:
https://paste.md-5.net/xevetayebe.java
making singleton classes has cleared up my main so much $_$
it was 65 lines before lol
Nice :)
Amazing
@celest current No need to do a == check to true. That's just redundant
Your getInstance is missing the null check
it's allowed me to make the saver final too ๐
you don't need to add the "this."
hat materials cant be used for crafting? because for some reason whenever i try to use Iron Ingots in a crafting recipe the recpie no longer exists
you don't need to add the "this."
@balmy sentinel Not needed but it makes your code more readable.
better would it to change to super.
so you always know it refers the the class it inherits from.
hat materials cant be used for crafting? because for some reason whenever i try to use Iron Ingots in a crafting recipe the recpie no longer exists
I just realised that bukkit already has a class called ItemFactory :/
It's for ItemMeta
and I named my ItemStack factory class ItemFactory ;-;
That's fine just make sure you import the right one
All materials work fine for crafting
aight
Well guys, I'm going to eat
Aside from ones that don't exist as items
See y'll soon
@celest current No need to do a == check to true. That's just redundant
@mellow wave if I only have one = than this happens: http://prntscr.com/tty34s
don't add any at all
@wispy pewter ty
because the = operator is used to define variables
You can just do if (boolean)
just use if(boolean)
Remove = true @celest current
I would also recommend to create a custom variable for the getconfig
so you dont have to write that piece of code everytime
.getBoolean("crafting.xp-bottle") already has a boolean value
by default, if() will check if something is true
And the way you're getting the recipe is depricated an item may have multiple recipes
var config = instance.getConfig();
so you don't need to check if it's true, as the if statement already does it
try making your life easier
Add a namespaced key to your recipe
yeah asking if its true is redundant
lol this poor guy is being bombarded by a million criticisms xD
Nah mate I love it
Criticism makes you better
tru
Anyway did you see what I said about the way you're getting the recipes. Use Bukkit#getRecipesFor instead and read the list
Constructive criticism makes you better
The people in this community are mega bigbrain so their criticism is usually really good advice
@celest current When you have to write a line ass line to acces something, Make it easier by making a custom variable
It makes your life way easier
And also makes your code cleaner ๐
Incase you want to flex on some noobs
instance.config() = config or sumn like dat
var config = instance.getConfig();
uno reverse to the max
var doesn't exist in java
thats JavaScript
it works for me ๐
Yeah I believe 10
Hmm
its not in 8
Olivio/MichielA, can't private fields be changed using reflection, so making them all private is kind of redundant?
@wispy pewter JDK 14, most servers use 8 which does not have var
Yeah could be related to the version of java
Just because they can doesn't mean they should
@wispy pewter JDK 14, most servers use 8 which does not have var
@mellow wave Ooh oke. Didnt know that, thanks.
I've always used 8 so I didn't know they added var
If someone is using reflection they should know that the field wasn't meant to be changed that way
fuck off bot
Reflection can access anything
^ It's really useful
right, so what's the point of making everything private and making getters and setters
if it can be changed by reflection?
why not just leave it public
Mentions one person
Reflection is slow
why not just leave it public
@formal nimbus Because private fields can only access in the calss itself
Yeah I have 2 warnings for typing the same message 2 times :&
And encapsulation is good practice
@formal nimbus Because private fields can only access in the calss itself
@wispy pewter but they can be accessed using reflection...
Plus getters and setters can add additional logic
And encapsulation is good practice
@lone fog but why
Reflection is slow and if someone uses it they most likley know what they're doing. I doubt some new to java would use it
right soo
it's to stop values being changed by people who don't know what they;re doing?
reflection is more for advanced users
@formal nimbus https://www.javatpoint.com/access-modifiers
Access modifiers in java or java access modifiers such as private, default, protected and public with examples applied on data member, method, constructor or class.
Anyway don't worry about someone using reflection on your class. If someone messes up it's their problem
Now i need to go afk
Anyway don't worry about someone using reflection on your class. If someone messes up it's their problem
I guess
It 100% is
I could use reflection to change true to false, but that would break everything and it would be my fault
I dont want to leave xD
instance.getConfig().getBoolean("crafting.powerdirt") still doesnt work tho? Its set to false in config but I can still craft the almighty dirt cube of ultimate power and strength
having to much fun
I literally eat, shit, breath binary
repeat
If you have security concerns you can use a SecurityManager
If you have security concerns you can use a SecurityManager
@lone fog lol I don't, but I'm just thinking of programmes which need security
If you want security go obfuscate your code
They probably will use C++
right
Or some obfuscation
hey guys
hey
hi
Why do all the comments of my configuration file disappier
in BungeeCord not spigot btw
My code rn is:
try {
if (!getDataFolder().exists())
getDataFolder().mkdir();
File file = new File(getDataFolder(), "config.yml");
if (!file.exists()) {
InputStream in = getResourceAsStream("config.yml");
Files.copy(in, file.toPath());
}
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));
config = configuration;
} catch(Exception ex) {
System.out.println("Erro a criar o ficheiro de configuraรงรฃo. Comandos, eventos e outras funรงรตes serรฃo desativadas. Por favor contacte o desenvolvedor (Picono435#2011).");
ex.printStackTrace();
return;
}```
Unless you write your own implementation
so... how do I solve this? hahaha
Also, does bungee not have saveDefaultConfig?
nop
i have my own yaml wrapper
it does not
not sure if any of you is interested
If u can send me it for I see how it is...
@tiny dagger Any chance I could take a look ๐
java.lang.UnsupportedOperationException: null
at com.google.common.collect.ImmutableCollection.clear(ImmutableCollection.java:294) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at com.javaminecraft.Elytra$1.run(Elytra.java:117) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at net.minecraft.server.v1_16_R1.MinecraftServer.b(MinecraftServer.java:1061) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at net.minecraft.server.v1_16_R1.DedicatedServer.b(DedicatedServer.java:354) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1009) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:848) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot.jar:git-Spigot-0509002-7c03d25]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]``` halp
it's just a wrapper of what there is already
it just makes it cleaner
and easier to translate to whatever type
with custom deserializer if i choose so
how do i get the time of day in minecraft
I still dont know what is causing the comments to disappier
Click F3
oh in coding lol
Use the java docs please... I've already told you @hollow thorn
It's not hard to search
take a look on the code
I have the method somewhere there
to see the time
in the main class if Im correct
so any idea of what can be causing the comments to do PUFF in bungeecord?
Yaml doesn't store comments in anyway
^
It's litteraly invisible
But I copy them
That's what I've been doing
as file
File file = new File(getDataFolder(), "config.yml");
if (!file.exists()) {
InputStream in = getResourceAsStream("config.yml");
Files.copy(in, file.toPath());
}```
use json if you want comments save
Configuration configuration =
ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));```
oh then this is the line that is causing the issues?
json isn't that user friendly
Yes if you save that with edited values it will loose comments
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));```
i feel like if i switched to it i would have people scream at me ๐
Why do you load and then save it right away
its what was in the spigot docs?
uh let me try removing it hum
testing..
uh lalallalalala
love u guys ty
:3
Hello! How can I store a custom data (Custom Tag) in an ItemStack?
Ahh ๐ค
far better than custom item tag ^^
Okay, thanks!
uhhh
I'm getting a null
line 28
no idea why?
it has a config...
and the config has been working fine ):
up until now
I know that I should probably ask this on the forums, but has anyone else noticed that mobs are spawning on top trapdoors?
I am on the latest version of spigot
I think that's normal...?
Hi, Are you familiar with the plugin "jail"?
How do I make it with MySQL like Coins You got in the last 7 Days:
Yesterday: 5 Coins
Sunday: 10 Coins
How do I make it with MySQL like Coins You got in the last 7 Days:
Yesterday: 5 Coins
Sunday: 10 Coins
@umbral dirge like you want to save how many coins a player gets each day?
Yes
I would create a new table coin_log and save the user's uuid, their amount of coins earned, and the timestamp. When you want to check how many coins a player earned on a certain date SELECT * FROM coin_log WHERE uuid=playerUUID AND date=date;
Lol i just looked up some code i wrote a year ago and the first thing i thought was, i should be send to prison.
@hollow thorn no, it will always increment by one
Hey! can I get item id from ItemStack?
@formal nimbus assign the field under the enable method
if (location.getBlock().getType().equals(Material.CHEST)) {
chests.put(key, location);
How come location#getBlock() returns null when its annonated @Notnull
a block can be null?
Guys what is best Java decomplier ?
I use JD-gui
Windows vista
@fluid marlin it shows everything?
@fluid marlin how are you so sure the getblock is null?
Maybe its something without the gettype
Thst means the getblock method cannot be null
Add a null check only for getblock
Hello everyone I have a problem with this java method that generates me a NullPointerException
but I can't find the error
Send the method
itemStack.getData().getItemType().getId() has deprecated, so how can I get the item id?
in what version of Minecraft?
1.15.2
the number id?
You'll have to use a library for that
Don't know why you'd want it because they're dumb
after 1.13.2 all id's have been archived as deprecated you don't have to use the id in this version
just make 2 version jeez
lol
don't use workarounds
it's just gonna bite you
you could make a legacy version from 1.8.8 up to 1.13+ just fine i think ๐ค
Hi
can someone help me with bungeecords configuration system?
Is there any way to load a resource as a template configuration and update a already existing config file on the server with it?
like checking if paths no longer exist in the template
and adding some if they are missing
and replacing values if the object type doesn't match
I thought maybe loading a resource stream would help me, but
there is no default values system
so
i would need to do it myself
but
its not that easy
via iterating through everything
i tried to do that
Numeric ids have been deprecated for over 5 years
Why would anyone still use them
^
but theres no in depth key searching
And why would you need that
i could only get the root keys
and iterate through them
but i have no idea where to start
with coding that
(a recursive key searcher)
U mean copying unset values from a fallback config?
Why would anyone still use them
They're easier to type.
I still wish I could give myself 137.
๐ค
They're easier to type, but harder to remember
the new id system
Material enums are compatible with more versions
were talking about item ids?
The new material enums are easier to remember ๐ค
They were even deprecated in 1.7
can someone please help me with my well detailed issue?
i am really struggling with this one
i think bungeechat just saves objects instead of yaml
but thats not the goal i want to achieve
why is there no system like in bukkit?
that would make devs the work much easier
for some reason this Bukkit.getWorlds().get(0).getTime()/1200 isnt working
what is Bukkit.getWorlds().get(0).getTime() returning?
Should be a long from 0 to 24000
timee.setProgress((Bukkit.getWorlds().get(0).getTime()/1200));
i dont know for some reason it isnt giving anything inbetween 0-1
Divide by 24000
but that will give me over the hole day
i only want over sun time
so when it is over 1 i made a small if statement that just sets it to 1
what is Bukkit.getWorlds().get(0).getTime() returning?
that doesnt change the fact that it doesnt seem to be giving me a decimal
it returns a long
I'm sure that's mostlikely going to be a floating point
@formal nimbus assign the field under the enable method
@wispy pewter sorry I was afk
will look into it now
@wispy pewter hasn't worked ;-;
You are assigning the config field before the on enable method is called
Assign the config under the enable method
no?
Assign the config under the enable method
@wispy pewter yessir
still happening ๐ค
Show me again
Wait
You are calling saver.getInstance
I think getconfig is null ny default
it won't let me instantiate it ):
it just says type FileConfiguration can't be instantiated
You are calling saver.getInstance
@lone fog ....
Kek
@lone fog that should work as long the saver class has been loaded first
yep
Oh wait that class is inside his plugin
I thought it belonged to a different plugin
?paste
You have a null at line 266
Hey, so I opened up a CommandMap forum over on spigot, would someone be kind to help me on my quest to fully loadable and unloadable commands ๐ https://www.spigotmc.org/threads/register-and-unregister-commands-in-runtime.456130/
You have a null at line 266
@lone fog ```if(item.getItemMeta()!=null &&item.getItemMeta().getLocalizedName().contains("watch")){
Biome b = loc.getBlock().getBiome();
String world = loc.getWorld().getName();
String x= String.valueOf(loc.getX());
String y= String.valueOf(loc.getY());
String z = String.valueOf(loc.getZ());
String biome = String.valueOf(b);
biome.toLowerCase();
StringUtils.remove(biome, "_");
StringUtils.capitaliseAllWords(biome);
List<String> text= new ArrayList<>();
text.add(e.getPlayer().getName()+":"+" World:"+world);
text.add("X: "+x+"Y: "+y+" Z:"+z);
text.add("Biome:"+biome);
String entities="Nearby";
for(Entity ent:e.getPlayer().getNearbyEntities(50, 50, 50)){
entities += String.valueOf(ent.getType());
if(ent.getCustomName()!=null){
entities+=" :"+String.valueOf(ent.getCustomName());
}
entities+=" , ";
}
text.add(entities);
ItemMeta im = item.getItemMeta();
im.setLore(text);
item.setItemMeta(im);
me.updateInventory();
}
}
}``` this is the code leading up to line 266 and after it
?paste
^ that too
the if statement
if(item.getItemMeta()!=null &&item.getItemMeta().getLocalizedName().contains("watch")){ is line 266
?paste
@frigid ember why didnt that work
NANI
Bot is slow
?paste
with the item being used it has a localized name
Doesn't matter add the check
also is this error exactly the same to the last one https://paste.md-5.net/ibovixebis.cs
Not the same
That error is an ArrayOutOfBoundsExeption
You tried to use a value in an array that doesn't exist
In this case the ArrayList on line 278
Now you should probably learn how to read those errors, there are guides online
People really need to read their errors and understand what they mean.
That error is an ArrayOutOfBoundsExeption
@mellow wave found out what it was used the wrong variable
Alright but still you should look up how to read those errors
Not only read. Also what they mean
Yeah that's what I meant xd
๐
Java 14 helpful npe flag ๐
oh yes
Who also doesn't like python?
Ivan iirc
hot take: brackets are better than forced indentation
for some reason my plugin only works after i have reloaded it
Exactly
looks like you're trying to load stuff before it actually loaded
Whats the best way to check if a player has certian items in inventory? This is what I have and it doesnt seem to go into the next part after Checking for Gold Ingot:
if(inv.getItemInHand().getType().equals(Material.GOLD_INGOT)){
ItemStack pin1 = new ItemStack(Material.POTATO, 1);
ItemStack pin2 = new ItemStack(Material.LEASH, 1);
if (p.getInventory().contains(Material.POTATO) && p.getInventory().contains(Material.LEASH)) { p.getInventory().getItemInHand().setAmount(p.getInventory().getItemInHand().getAmount()-1);
p.getInventory().remove(new ItemStack(pin1));
p.getInventory().remove(new ItemStack(pin2));
}
}```
Use == instead of .equals() when comparing enums
if (inv.getInventory().getItemInMainHand().getType() == Material.GOLD_INGOT) {
// le code
}```
Might fix your problem, but put some debug outputs in there to see how far it gets
ok ty
Use == instead of .equals() when comparing enums
if only Java had operator overloading...
with Java, when comparing things, you'll almost always need to use equals
If you're working with multiple enum checks i recommend using the switch-case statement
^
Cleaner and faster Code
well in reality it will need to check if you have 25 different items in your inventory and ifso remove 1 of each and run the rest of code
Im testing with 2 before adding more
in that case definitely use a switch-case statement.
if you dont know how switch case works, here is an example.
Animal Enum:
public enum Animal {
DOG, COW, CAT, SHEEP
}
Switch-Case
public class Main {
public static void main(String[] args) {
Animal animal = Animal.CAT;
switch (animal)
{
case DOG:
Log("Doggo");
break;
case COW:
Log("Big Cow");
break;
case CAT:
Log("Cat");
break;
case SHEEP:
Log("Sheep");
break;
}
}
static void Log(String msg)
{
System.out.println(msg);
}
Oh.... I think (maybe im wrong) but I wanted it to check if player was holding the gold_ingot in main hand, then if true, check if they are holding 25 other items in their inventory, and if true remove 1 of each item of the prior 26 materials and run an event so switch-case wouldnt work?
Anyone has an idea whats the best way to make a 1 Block wide world?
When i use the ChunkPopulateEvent it crashes the server
And I have no ideas with ChunkGenerators
ok, I've been trying to make a NPC plugin. rn I have it so that when you shift + right click it selects the NPC. I dunno how I want to store which NPC is selected but if someone knows, that would be AWESOME!
@solid sundial I'd just use a hashmap
with the player uuid as the key and the npc or entity object
public static Map<Player, EntityPlayer> map = new HashMap<>();
I'm not experienced with messing with packet generated entities but aren't packet generated entities not real entities?
I'd recommend giving the npc an id and call to it using some other method to retrieve it
yeah
i've been wondering if I should make some kind of id, but i dunno how...
do you?
wat
why is that map static exactly?
A npc will also have an uuid use that not the npc object
it is static because i want to use what is in the Map in my commands
wait, a uuid
how can i find that?
wat that
Dependency injection is not needed probably
Singleton is fine
Dependency injection is more for working with Interfaces
i guess ill just mess around with the syntax ๐
People can't write, doesn't write enough rights! What to do? Plugin: ChatEX
ok, so when player selects.
map.put(event.getPlayer(), event.getNPC());
what should i put instead of getNPC?
I'd honestly store just the uuid of the player, and the uuid of the npc
so...
so it stores less information in the cache
@hollow grail What permissions plugin are you using
I typically just use the UUID format, is there a particular benefit to using a ulong?
i dunno what you are talking about? but what should i put instead of getNPC... lol
im confused
@winged sparrow Its in long xD
I forgot java doesnt support unsigned integers does it?
so, new Map<UUID, UUID> map = new Map<>()
I wouldnt really recommend using a class as key
UUID is 128 bits -> 2 longs
๐ the more you know
yes
i'm used to C#
@frigid ember luskperms
where we have uint, ulong etc
hence why you store it in a database as BINARY(16) and not varchar
npc is my class
but I didnโt do anything in it, it was just installed.
I like Struct
how to get the UUID of that specific npc... am i stupid idot
Well if it's a EntityPlayer, there should be some kind of method to retrieve it
getUniqueId()
is the method you use for getting uuids from players and entities
UUID = Universally unique identifier
yeah... getUniqueId of player works
but when i do NPC.getUniqueId it asks me to make a new method
cough except for minecraft devs
bedrock
EntityPlayer is a nms data format, right?
you're gonna have to do some digging for that.
Check the docs lol
There is a reason why there is something called "Docs"
@hollow grail you need to give the players the correct perms for ChatEX to type then
wait, some of you are saying to make my Map <UUID, UUID> and some are saying <UUID, EntityPlayer> which one
Is it a bad idea to hijack player messages on the chat event and replace it with a textcomponent?
Store two uuids
one for the player, one for the selected npc
I don't recommend storing class objects in maps
Good luck!
thanks ๐
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
nmsPlayer.getUniqueID();```
@solid sundial
getUniqueID() is a easily accessible method from an entity player
And that will give it to you
see my mistake
That should be exactly what you need
THANK SO MUCH EVERYONE!
SOmeone's happy
map.put(Player#getUniqueId(), NPC#getUniqueId();```
Good luck!
Memoryoverflow
Oops i forgot its Brain.jar
Feminists
If in a future version, the Inventory#getItemInHand method is removed and only getItemInMainHand will be left, what would be the way to make the plugin backwards compatible down to 1.8 where getItemInMainHand didn't exist yet?
Don't.
I'm looking for a way to do it, not for a way to just not do it at all
Abstraction or reflection i suppose
Abstraction is probably best
Though I don't think MD likes to remove stuff like that anyway
He will probably rip it out suddenly when he feels like itโs annoying
Like getTitle in an inventory
Somesomething inventories donโt sctually have titles or smth
Alright, thank you guys. I'll take a look into abstractions.
So basically deprecate = never remove but anything else can be removed at any time ๐
According to the internet it was deprecated in 1.13
Deprecation in bukkit is ๐คท๐ผโโ๏ธ
Was prolly removed in 1.13
help
Kicked whilst connecting to lobby: If you wish to use IP forwarding, please enable it in your BungeeCord config as well!
'tis plain english
Imagine if stack traces were random text without any meaning
hey, after updating my server and all plugins from 1.15.2 to 1.16.1 i'm getting tons of these messages
[21:44:59] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 8286ms or 165 ticks behind
[21:45:37] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 8128ms or 162 ticks behind
[21:46:15] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 8019ms or 160 ticks behind
[21:46:53] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 7814ms or 156 ticks behind```
and TPS drops that I was not having before. A fresh install of the 1.16.1 server reproduced the same issue. It was working perfectly fine on previous versions of Spigot
help
help
Kicked whilst connecting to lobby: If you wish to use IP forwarding, please enable it in your BungeeCord config as well!
no
@bold anchor can you send the "dog help no info" meme from paper pinned messages
it's in their #general
I'm the one who posted it in general lol
ah yes, paperhub
oh I thought you meant
Sry Phangout
error : https://paste.md-5.net/uxavewivep.cs
I'm getting this nullpointer for some reason?
e9d30742-403e-4726-8b0f-de85903ede35:
'0':
location: world, 205, 70, 293
reason: Lazinq fell out of the world
time: 1596497014631```
https://paste.md-5.net/iqafiqobog.cs
74:
public Location stringToLoc(final String input) {
final String[] args = input.split(", ");
__ return new Location(Bukkit.getWorld(args[0]), Integer.valueOf(args[1]), Integer.valueOf(args[2]), Integer.valueOf(args[3]));__
}
Does anybody know any free plugins similar to PlayerVault?
Anyone know if there is a way to convert
/summon fireworks_rocket -10 80 338 {LifeTime:20,FireworksItem:{id:fireworks,Count:1,tag:{Fireworks:{Explosions:[{Type:4,Flicker:0,Trail:1,Colors:[I;16777215],FadeColors:[16777215]}]}}}} to API? (like some conversion tool to help, I have about 240 of these)
probably no tool
I would say make your own /summon that takes those args and gives you something more useful for usage with api
and then just run your 200 commands
or just make a parsing script
So, I remember Spigot having this Ore Hider (Once Upon a time). Is there a way to Enable it? Or a Plugin that is very good, and works with RSS packs/Mods?
@ me ๐ if you have an answer โ๏ธ Up top(since you donโt read upwards.
pretty sure Spigot removed it a while ago
There's this though (updated to 1.16), https://github.com/Imprex-Development/Orebfuscator
Thanks.
Now Finding The right amount of Packets to Send/Receive. To help with mods. xD
๐ค Nvm, I think I tab saved that one.
Cause u doing it wrong
It does tho
then tell me what is wrong
it doesnt matter which version i use
Why not use latest then
o
yeah now the bot starts... thanks
Can someone point me in the right direction on where to learn how to grab an armorstand at a specific location that I can edit its pose?
declaration: package: org.bukkit.entity, interface: ArmorStand
And use getNearbyEntities
excellent, thank you
@quick arch uh did you mean javaplayer not lavaplayer?
no, lavaplayer
oh
It's audio for Discord Bots
oh that makes more sense
player.sendMessage(applyCC("&6World:&f " + data.getLocation().getWorld().getName() + " &6X:&f " + data.getLocation().getBlockX() + " &6Y:&f " + data.getLocation().getBlockY() + " &6Z:&f " + data.getLocation().getBlockZ() + " &6Reason:&f " + data.getReason() + " &6Time:&f " + data.getTime()));```
&6Time:&f " + data.getTime()
so Im sending this
Any staff who can help me with a purchase problem?
Why are you creating a simpleDateFormat and not using it
but it will literally give the System.current.timemillies
yes
how can I properly use it?
I tried it
but then it says it hasnt been itialised
I put it like this:
death.add(new Data(e.getEntity().getLocation(), e.getDeathMessage(), System.currentTimeMillis()));```
System.currentTimeMillis()
then it should be converted to the regular time
when the command gets executed
sDF.format
SimpleDateFormat sDF = new SimpleDateFormat("HH:mm");
return sDF.format(time);
Won't be a long anymore
Think it's a string
yes
millieseconds since 1997 yea
but can be converted to real time
death.add(new Data(e.getEntity().getLocation(), e.getDeathMessage(), System.currentTimeMillis()));
System.currentTimeMillis() = long
1970 actually
so what should I put
SimpleDateFormat sDF = new SimpleDateFormat("HH:mm");
return sDF.format(time);
yea
but put it into the hashmap
deaths.add(new Data(e.getEntity().getLocation(), e.getDeathMessage(), System.currentTimeMillis()));
System.currentTimeMillis = long
Derp question but this:
(from /summon armor_stand) Pose:{LeftLeg:[56f,46f,63f]}}
``` Are these EulerAngles? Or do I need to find a way to convert this?
hi guys, could do with a little help, currently lava donesnt damage people and creeepers dont blow up on my paper server
they charge but no explosion
Check paper.yml
those are disabled then
@lone fog
says its 1.23 rn
while its 2.57 here rn ๐ฆ
ohh nvm
srry for ghost tag
what am i looking for exactly, i dont see creeper explosions
Lets rule out something first, Are you using worldguard also?
yes
in worldguard > config.yml
block-creeper-explosions: false
block-creeper-block-damage: false
player-damage:
disable-lava-damage: false
Look around the config to setup how you like then save and restart server ๐
ah okay, thanks. I was looking in the wrong plugins. I thought it was related to the spawn in particular
All good, I went though the same thing almost when I first started a server
so given i am disabling creeper block damage. This will be unaffected with claims inside of redprotect. not sure if you have experience with it?
havent used redprotect so unsure....
this may be a stupid question, but I just started using bukkit/spigot. Is there a way to get rid of the stupid bukkit help that replaces /help and maybe even create a whole new version of that
and does anyone know what the best permissions tutorial is
hey guys, i have another question. Using votifier and votingplugin. Is it possible to give essentials balance increase as a reward?
Is there a discord for NoCheatplus.
System.out.println() & System.out.print() both return spaces, correct?
Is this the place to go when you need help with plugins?
yes
@lone fog where abouts is this stated? here under rewards like this?
VoteDelay: 24
Item:
Material: 'TRIPWIRE_HOOK'
Amount: 1
Chance: 100
Name: '&aPirates Chance Key'
Enchants:
fortune: 1
Rewards:
Commands:
- say hello
AdvancedPriority:
Reward1:
Money:
Min: 100
Max: 3000
EXPLevels:
Min: 1
Max: 5
slash needed?
Im using NoCheatplus in 1.16 but it's blocking crossbows how do I fix it or replace what to replace it with.
Can anyone help me or there is another server to help with this problem.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockCanBuildEvent.html but a cancellable BlockPlaceEvent already exists, what's the difference?
BlockCanBuild is thrown when you try to place a block, even if you can't place it for x reason
for(i=0, j=10; i < j; i++, j--)
System.out.println("I and J: " + i + " " + j);
```So this loop will end when I is greater than J?