#help-development
1 messages · Page 2089 of 1
public ConvertBlocks(Material a, Material b, Nullable boolean visual, Nullable double chance)
Example of a builder pattern?
there's also the optional keyword but it's a pain
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.
shit that ends with .build()
u prob alr seen it
no
thats what i did tho
is there any way of getting a tnt entity when it spawns in? through some event
such a long discussion for such a simple problem lmao
ye lmfao
wow
huh i already employed method chaining, thought i thought it to be the wrong wy to use it. Returning this seemed wrong somehow
if only someone told him that right at the start!
.
method chaining is the way to go here, it sounds bad at the start but boy you will fall in love with it when you realize just how much it frees you and how much cleaner everything becomes
@Getter
@Builder
public class Widget {
private final String name;
private final int id;
}
Widget testWidget = Widget.builder()
.name("foo")
.id(1)
.build();
noted. So im going to write a constructor for those not nullable args and do the rest via method chaining
thanks
np
tnt entity do u mean one thats exploding
prob not
Is it safe to do instance comparision with worlds or should I rather do equality comparision?
that's not what instances are for
could you specify that a bit more precisely?
like from a dispenser or something
unless I've been living a lie instanceof will tell you if a class is of the same type or extends another class
@Builder(builderMethodName = "internalBuilder")
public class RequiredFieldAnnotation {
@NonNull
private String name;
private String description;
public static RequiredFieldAnnotationBuilder builder(String name) {
return internalBuilder().name(name);
}
}
i love lombok
its really weird how that hasnt been a thing for how ever many years
its a simple thing to add
Ah, I was talking about == when I was talking about instance comparision
not in libraries or APIs tho
i dont have access to the source of the jar thats used
ah, == is fine and I believe null-safe
packets?
not sure, i'd have to search me
afaik worlds are singletons
at least I am pretty sure but I will say I historically always do .equals even though I don't have a real reason to do it
guessing it had to do with someone doing somethin with item swaping
how else would you do it then
thats about the only time i can think of it being useful
is it abstract?
wtf am I doing wrong?
SELECT serialized_object FROM ? WHERE serialized_id = ?
statement = connection.prepareStatement(SQL_DESERIALIZE_OBJECT);
statement.setString(1, table);
statement.setString(2, uuid.toString());
ah yeah it is
Thing's giving off an invalid syntax error
doesn't it trigger an entityspawnevent
tnt entity is kind of weird
i could not for the life of me get a way to detect when someone left clicks a primed tnt
i tried pretty much everything
did you try ExplosionPrimeEvent?
assuming explosionprimeevent works which it probably should all you need to do is get the entity and raytrace player hits
intersect the two and you're done
Lol people thinking something isn't in the API like that
re-reading it specifically, I would have suggested it because it specifically targets only HumanEntity and cuts out work
sort of hard to tell just from the api comments
but yeah it is abstract
I do think it's hilariously phrased though
must be creeper ai
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
customizeshopGUI();//refresh inv
if (main.inventory.getItem(12) == null)return; //looks if item != null
if(main.inventory.getItem(12).getType() == Material.AIR) { // checks if item is air (normal empty slot is set to air)
System.out.println("air");
return;
}else { //if not air it runs this
System.out.println("called!!");
customizeshopGUI();
player.openInventory(main.inventory);
}
}
},0, 50000);
i got this code in the event on inventory click but it doesnt print annything? i added commands to make it more clear and it should just work if you wanna see the whole file check this link: https://paste.helpch.at/coxuwaferu.cs
old minecraft version if your using material.air?
start by checking if it runs at all when you add more text before the first break point
is it diffrent?
.equals not == 
sorry but its fine how I do it rigth?
are you getting an exception?
seems like getItem(12) might return null and you're using .getType on it
if they are air, should use isAir() since 1.18 has three types
i believe the reason for that is that since a certain version a itemStack being set to size 0 or Material.AIR deletes it
Mojang calls it vanishable i believe
if(!main.inventory.getItem(12).getType().equals(! Material.AIR) this is not good?
that is not a valid statement
i mean .equals doesnt really matter in this case
but also are you getting an exception
wrong
== for enums and primitives
yea
customizeshopGUI();//refresh inv
System.out.println("sorry");
if (main.inventory.getItem(12) == null)return; //looks if item != null
System.out.println("item is not null");
System.out.println("air");
System.out.println("called!!");
customizeshopGUI();
player.openInventory(main.inventory);
so just try this?
if (main.inventory.getItem(12) == null) {
return;
}
main class: https://paste.md-5.net/awativovog.java
papi class: https://paste.md-5.net/neyawoziri.java
why do the placeholders not work?
quick question anyone knowing how i can null terminate a string?
in java
like in c++
suprisingly the forums information is outdated and it does in fact get called
what does that mean?
ends with \0
still dont know
It’s a technique used in other languages to define the end of something.
java has a problem with them, so I am not sure you can use them safely
you would have to manually do it and then hope java doenst implode
probably a different way to do it
what are you trying to do?
the point of null terminating is to cut off whatever is behind the null terminator
subString?
writing my own way to parse commands
its replacing the \0 no?
and i want to be able to specify
the characters
use regex
no
many ways you could do that
subString comes to mind
\0 is supposed to delete whatever comes after it @tardy delta
dont i have to iterate it first then
the string
not exactly ...
?
ik
technically it nulls the memory at its mem address of the primitive string
const char*
to find the null terminators position to then use substring
hmm sec
just get wherever you're trying to insert the \0?
if you really wanted you could just do .split("\0")[0]
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
customizeshopGUI();//refresh inv
if (main.inventory.getItem(12) == null)return; //looks if item != null
System.out.println("item is not null");
System.out.println("called!!");
customizeshopGUI();
player.openInventory(main.inventory);
}
},0, 100);
so it doesnt call it when i put a item in slot 12
i dont understand why?
i believe they are trying to prevent adding to a command or injecting additional
whats wrong with bukkit scheduler?
what i originally wanted to do was like String.replace("{break}", '\0') xD @crisp steeple but figured its not that easy
hm
are you sure this is running at all?
is curious why you do this: if (main.inventory.getItem(12) == null)return; //looks if item != null
and you're sure if you put a print statement in the == null if statement it would print
I do that bc im checking if that slot is not nothing because otherwise if the item is null it will set an other slot to zero
in the end
aside from the inverted logic and forcing an early return, where is main supposed to come from?
its my main class i have a static inventory in there
i define that in the function customizeshopGUI();
check console for errors
nothing
so everyone is just supposed to use the same inventory?
nah just testing
so why do you call player.openInventory(main.inventory); if it is false?
trying printing out all the contents of the inventory and see what happens
if whats false?
the null test
also just wondering why you're using a timertask instead of bukkit runnable
that works so its not the point
but i checked of the timer works and it did?
if the timer is working, I am not sure you are accessing the inventory you think you are
just because the timer works doesnt mean itll always act correctly ingame
so how would you make a timer
I believe that Runnable#runTaskTimer() exists.
[20:29:02] [Server thread/INFO]: ItemStack{RED_WOOL x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"red","text":"Cancel"}],"text":""}}}
[20:29:02] [Server thread/INFO]: ItemStack{OAK_SIGN x 1, TILE_ENTITY_META:{meta-type=TILE_ENTITY, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"Set the title"}],"text":""}, blockMaterial=OAK_SIGN}}
[20:29:02] [Server thread/INFO]: ItemStack{OAK_SIGN x 1, TILE_ENTITY_META:{meta-type=TILE_ENTITY, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"Set the description"}],"text":""}, blockMaterial=OAK_SIGN}}
[20:29:02] [Server thread/INFO]: ItemStack{BLACK_STAINED_GLASS_PANE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"text":" "}],"text":""}}}```
new BukkitRunnable(){
@Override
public void run(){
// do stuff
}
}.runTaskTimer(<plugin>, 0, 100);
i count 5 itemstacks ?
Keep in mind that the delay and period parameters for BukkitRunnables are in server ticks. Not milliseconds.
i like the lambda way
with the shheduler
yea just writing the code in discord chat lol
kek
so you always force return according to your test ...
i would really recommend switching to a bukkit runnable if you havent already
if you try to check or modify something between ticks that can break things
im asuming <plugin> is the name of my plugin?
the actual instance
?
so the name?
wtf do you mean with that?
you can call multiple instances of your plugin
should it just be: <plugin>
<plugin> is your plugin object
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i dont know how else to put that
you want to use the one it belongs to
you can get the instance either with dependency injection or static getters
Is there an easy way to turn a string into a location? cause i found this(https://bukkit.org/threads/solved-convert-string-to-location-then-tp-the-player-to-the-location.68656/) but what i'm confused about is that i'm unsure of how i can make that location in a different world, cause i have the overworld and then i have arena which is a world i want to teleport into (I guess more dimensions then worlds?) using the location i put into a config but that is of coarse a string
@NotNull
public HandlerList getHandlers() { return handlers; }
@NotNull
public static HandlerList getHandlerList() { return handlers; }
public static DimensionalOrder getPlugin() { return plugin; }
public static DimensionalOrder getInstance(){ return instance; }
public static DimensionalOrder getEvent(){ return event; }
nice discord ..
Hey do you know how I can put HEX color in a scoreboard ? Thats work for my title but thats didn't work for the objectives
String title = ChatColor.of("#25bfbf") +"S" +ChatColor.of("#29bdad")+"e" +ChatColor.of("#2dbb9b")+ "a" +ChatColor.of("#32ba8a")+"O"+ChatColor.of("#36b878")+"f"
+ChatColor.of("#3bb767")+"S"+ChatColor.of("#3fb555")+"k"+ChatColor.of("#44b444")+"y";
ob.setDisplayName(title);
Score s2 = ob.getScore("§7│ §e▪ "+hexColor("#24E48A")+"Grade§f: " + SCOREBOARD_UTILS.getGroup(p));
Score s3 = ob.getScore("§7│ §e▪ §aConnectés§f: §e" + co);
Score s4 = ob.getScore("§7│ §e▪ §aPlayTime§f: §e" + SCOREBOARD_UTILS.playerTime(p));
Score s5 = ob.getScore("§7│ §e▪ §bTempFly§f: §e" + SCOREBOARD_UTILS.getFly(p));
Score s6 = ob.getScore("§7│§b");
Score s7 = ob.getScore("§7│");
Score s8 = ob.getScore("§7│§e");
Score s9 = ob.getScore("§7│ §e▪ §aRôle§f: §e" + SCOREBOARD_UTILS.getRole(p));
Score s10 = ob.getScore("§7│ §e▪ §aNiveau§f: §e" + level);
Score s11 = ob.getScore("§7│ §e▪ §aArgent§f: §e" + SHORT_MONEY.getShort(MoneyAPI.getMoney(p)));
Score s12 = ob.getScore("§7│§0");
Score s13 = ob.getScore("§7│ §6VoteParty§f(§e" + 0 + "§f/§750§f) §7━");
you could either just directly set the location in config, then get it and change the world
or make your own system that only stores the coordinates
and then converts it to a location
if you have the "arena" world object you should be able to call getLocation or getBlock one of the 2
(second option is best if you are planning on having many locations stored)
and then get the x,y,z variables from the converted location
So get location in the arena and then call the xyz from my converted location?
public Location stringToLocation(String location) {
String[] str2loc = location.split(",");
Location loc = new Location(plugin.getServer().getWorld("arena"),0,0,0);
loc.setX(Double.parseDouble(str2loc[1]));
loc.setY(Double.parseDouble(str2loc[2]));
loc.setZ(Double.parseDouble(str2loc[3]));
return loc;
}```
why not just set the variables on initialize?
No idea i somewhat copyed it from that thread
you're starting the array index at 1?
not great idea to just blindly copy code
0 was meant to be where "arena" is
Yeah which is why i came here before running it
well that method will only work if you're storing your location like "world,x,y,z"
how are you then
SouthTeamSpawn: "0, 44, 65"
NorthTeamSpawn: "0, 44, -65"```
start at 0 then
That's the config
wdm
"0,44,4" over "0, 44, 4"
What's wrong with being able to read it
because then youll have to filter it out later
I'm not 100% but I don't think it works with parsing doubles
ah
ok
so this
SouthTeamSpawn: "0,44,65"
NorthTeamSpawn: "0,44,-65"
then this for the method
public Location stringToLocation(String location) {
String[] str2loc = location.split(",");
Location loc = new Location(plugin.getServer().getWorld("arena"),0,0,0);
loc.setX(Double.parseDouble(str2loc[0]));
loc.setY(Double.parseDouble(str2loc[1]));
loc.setZ(Double.parseDouble(str2loc[2]));
return loc;
}```?
should work but you might want to filter out the spaces
I cut the spaces
ok then yeah it should be fine
but when you create the location you can just do
new Location(world, loc1, loc2, loc3)
save some lines
excuse the formatting I'm on my phone
yep
I was wondering why the thread didn't do that
figgerd it out it doesnt refresh the invetrotory bc it cant see it
bc i dont define the item when its selected
So instead of setting i can cut those and put the parses in place of the 0s?
is the scheduler reset over server reboot or can i schedule a task for a real-time day of ticks in the future and let the server restart at midnight
that would do it
it's from 2012
Yeah
That would explain it
you would need to get the amount of time between whenever you start the runnable and midnight and convert it to ticks
how would that help?
so this should be better:
public Location stringToLocation(String location) {
String[] str2loc = location.split(",");
return new Location(plugin.getServer().getWorld("arena"),Double.parseDouble(str2loc[0]),Double.parseDouble(str2loc[1]),Double.parseDouble(str2loc[2]));
}```
Indentation is off cause message length...
Do i need new?
removing it says yes so i shall keep it
ye
So this should return a new location in the world of arena?
yes
Awesome
can i use /reload to test new builds or should i restart the server
restart
reload works but if ur code is bad u will have memory leaks
depends on the plugin
under resources
i have it in resources but it cant find it
whut
The embedded resource 'config.yml' cannot be found in plugins\generalutils-1.0-SNAPSHOT.jar
why is main there
it has the plugin.yml in it
ok
wait
do i need to add something else in like plugin.yml for the config to work
no
i have this in my on enable: if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new SomeExpansion(this).register(); } and this is my someexpansion class: https://paste.md-5.net/ogagulugoj.java, i put %disabler_kills% in the scoreboard and its spamming [18:57:28 WARN]: org.apache.commons.lang.UnhandledException: Plugin Scoreboard-revision vR4 1.1 RELEASE generated an exception while executing task 85 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NullPointerException in my console
Is there a way of saving a resource to a different folder then the normal data folder?
so why cant it find the config.yml file?
cause your directories are all messed up
do i need to add it in gradle?
JavaPlugin::getConfig() ?
😔
intellij has an option to add it to your build path
send the expansion class
wait
nvm
yes
you're still loading this class despite the fact those classes might not exist
what that mean
well i fixed the plugin.yml
explain in monkey language
compile class means class must exist, if class no exist - bad stuff happen!
hm
I GOT IT
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
// vvvvvvvvvvvvv class is loaded no matter what! bad stuff happen!!!
new SomeExpansion(this).register();
}
i put it in the wrong resources folder
i think i put it in gradle resources or smth
you can use reflection
Class.forName("me.frandma.disabler.SomeExpansion").invoke(this).register();
or something like that
ok lets see if it works
ok
nice
try catch it
right click the error
what then
java.lang.ExceptionInInitializerError: null it is ```java
public static void setup() {
file = new File(Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("GeneralUtils")).getDataFolder(), "config.yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// oof
}
}
configFile = YamlConfiguration.loadConfiguration(file);
}```
basic java
you do realize Objects.requireNonNull just throws an exception if the provided argument is null, correct?
intellij dumb dumb
so remove it?
Class.forName("me.frandma.disabler.SomeExpansion").invoke(this).register();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}``` like that?
Plugin plugin = Bukkit.getPluginManager().getPlugin("GeneralUtils");
if (plugin == null) {
Bukkit.getLogger().severe("GeneralUtils was not found!");
return;
}
it doesnt make a difference
oh
it just moved the exception
actual error handling
i told u it was something like that
i think in never java versions you have to get the constructor
newInstance p sure
ye it didnt fix
whats this
what code
what is invoke
better code than what u had
if the plugin isnt found it tells the user and returns out of the function
ok
i use 1.8
e
try newInstance instead of invoke
k
wait no
these thigns on the side only work if theres one of them in the file
what
Class.forName("me.frandma.disabler.SomeExpansion").getConstructor(this.getClass()).newInstance(1);
try this
catch it
it didnt say not found and it had the same error
java errors suck
yes'
Class.forName("me.frandma.disabler.SomeExpansion").getConstructor(this.getClass()).newInstance(1);
} catch (ClassNotFoundException | NoSuchMethodException e) {
//monke
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}``` this happen because newinstance was red
java errors are some of the best you can get unless you're dealing with reflection stuff
you dont need all of that
well they could be more descriptive, instead of saying just the line calling the method that errors
if the code cant error, there are no errors
what
it tells you exactly where its going wrong
no
you cant expect the language to hold your hand throughout every single invocation
when the newinstance
oh what
it says its caused by the plugin being already initialized
Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
huh
what
u cant
true &= false == true,
false &= false == false``` correct?
private static GeneralUtils generalUtils = new GeneralUtils();
private static File file;
private static FileConfiguration configFile;
public Config(GeneralUtils generalUtils) {
Config.generalUtils = generalUtils;
}```could this be it
where do i do it then
ye
oh that wasnt for me
is GeneralUtils your main class?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
you need to learn java error handling
the tutorial lied!
yes
i dont feel like explaining all of it to you
where tutorial at
i hope no one is making tutorials where they instantiate the plugin multiple times
ty
the one i watched said to get the main class to get the logger
yes
that’s not a lie
i would make spigot plugin tutorials if i didnt run this account completely separate from my real life
thats exception handling tho
lol
u right u right
there’s a ton of tutorials out there people will just follow blindly and then have no idea how to work with it afterwards
why does java always like to be different
hahahaha
i didnt see ur message
an error fucks up the program
i said you dont want the reason
thats the first time thats happened to me, accidentally deleting someones message
panic!
lol
while exceptions are less KALM than errors (PANIK)
therefore handling errors is not something you wanna do usually
let option: Option<i32> = None;
// vvvvvv panic!
println!("{}", option.unwrap());
rust
ah
rust is the best language
no..
(opinion)
rust is literally so much better
rust can do everything java can do and its the fastest and most memory safe langauge
java is just convenient because it runs on almost all platforms
slap down some HDL and see how it performs for you
"VHDL is a dataflow language in which every statement is considered for execution simultaneously" tasty stuff
unless you like the verilog version instead
java’a decent but it’s definitely not the best
rust > you
mye rust is pretty much the future
if everyone focused on rust instead of c++ and java, everyday processes would be so much faster
ye indeed
different purposes than c++
yes
pub struct Options {
pub action: String,
pub path: String,
}
impl Options {
pub fn new(action: String, path: String) -> Self {
Self {
action,
path,
}
}
}
fn require_string(flag: &str, iter: &mut impl Iterator<Item = String>) -> Option<String> {
match iter.next() {
Some(value) => Some(value),
None => {
println!("flag `{}` requires an argument", flag);
None
}
}
}
rust code
i’ve wanted to learn rust for a while but it’s always just seemed to complicated
(plus my pc doesn’t have enough storage to install the compiler)
does your pc have 1gb of storage
pretty much yeah
anyways only time its complicated is when borrowing stuff and lifetimes
which is still more simple than what u'd have to do in cpp arguably
indeed
i think my main drive has like 40-100 mb left and external only has 700
ive always had interest in rust tbf
"If you are looking for a well-supported and framework-rich language, you will probably choose C++. In other cases, you might want your code to be extremely safe, avoid memory leaks and other undefined behavior then start learning Rust."
rust literally has a crate for everything
im sure i can find a hello world crate
nvm crates.io takes them all down
"Dart is a client-optimized language used in API development and in building mobile applications that require complex logic. It is in reality a concise and expressive language and is also more productive."
ive never heard of dart
it is the main competetor to rust
dart looks like shit
By design, Dart is a single-threaded programming language. That's mean we have asynchronous code across application. When a program starts, it creates something that is called Isolate. When isolated created, the microtask manager executes all events asynchronously.
seems unsafe
yes
sort of
but unlike Java which has a thread api directly exposed to language users
which is weird
since Dart is kinda Java + JavaScript combo
most processors these days now have builtin thread handling
mye
send dog pics pls
lol dont have any on my pc as of now
my personal thought is that the language that will surplant c++ is likely the main one that gets used for multi-state processors
tf is that
its just
code
fn println<D: AsRef<str>>(message: D) {
io::stdout().write_all(message.as_ref().as_bytes()).ok();
io::stdout().flush().ok();
}
you can do this or just use println!
mye I mean that can be different ones depending on what exactly you're doing in the backend
dude
autopilot got all of this from
1 sec
thats actually really impressive
import Quipper
spos :: Bool -> Circ Qubit
spos b = do q <- qinit b
r <- hadamard q
return r
yes haskell is nice
haskell implementation of the quipper language to prepare a superposition
but like sometimes statefulness helps you go much faster without losing too much brain cells
and like for things like IO you'd need a monad
which in itself can become a bit complicated
since you're doing everything purely from the outside (but yes some stuff is impure altho kept away from the user's consciousness)
looks like cancer
hahahaha
well you have a potential unlimited number of state results rather than a boolen
Happens on potato pc's
kill process, something is eatting up java ram\
ok
i cant run discord+spotify+intellij+edge together
how much ram u got?
system says 16gb on this laptop
hmm
i also have 16
whats the best way to update config file?
should i overwrite it or
I usually use config versions
would this work? https://github.com/tchristofferson/Config-Updater
i have one of those, to tell if its old. but how would i update it?
well if the config version is older, I just set default values for every key thats missing
ok, but what about comments?
ye well spigot supports comments
How do I set the timeout of a repository in maven? Some random repository is only partially responding at causes the build time to shoot up to 15 minutes which is not nice at all
also how can i create a permission for /gu reload without setting it for /gu
nvm im blind lol
well check if the first argument is reload and also check the permission
but how can i create the permission where it shows in the permission manager
declare one in plugin.yml
also is online players the default tab completion when there is none set?
yes
ok
well my custom tab completion isnt working
public class InfoTabCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equals("bring")) {
List<String> list = new ArrayList<>();
list.add("reload");
list.add("info");
return list;
}
return null;
}
}```
oh i know
you need to take arguments into consideration
well
what I mean is
lets say someone tab completes at /bring rel
now that'd result in /bring relreload
Oh
it actually doesnt
how wouldi put this string in teh config.yml? &4You don't have permission to use this!
yes
it works like normal
wait i see what your saying now
shouldnt be too hard to fix
this tho
then how would i put the ' in the string
is there an escape character like in python?
\
either "don't" or 'don''t' (two single quotes)
the " doubled the ' in don't
I got a Map<String, List<UUID>>
is it possible to get the String of a UUID?
Only by iterating
in the plugin.yml can i add subcommands like yml commands: generalutils: reload:
ok
i dont't think arguments are needed for the command to work
well those are the options if you wanna have a string that contains a single quote apart from unicode escaping
tehn how can i create a permission node
else you get a yaml parse error
that creates a node?
then how would i make it where i can see the permission in the pm?
if you want to use " inside a String you have to escape it
you declare permissions in plugin.yml but thats just to define properties of them, technically every permission already exists
but the pm wont show it unless i add it in plugin.yml
pm?
permission manager
literally isnt
yes, your permissions have to be registered
but the only way i see how is to register it with a command, which permission locks the command
well zacken ’ is not '
you can define any permissions you want in your plugin.yml
check the documentation on spigot for plugin.yml
key: ’blah’ would not be parsed to blah but ’blah’
i cant check the docs im at school they block it
dang cant u just like say the syntax
the syntax
That yaml parser works great
I mean
we can try 50 different parsers
each one will yield an error by definition
uk what im gonna write a unit test that proves you wrong using snake yaml just to show you
^
You can't just, deny the rules?
I think he just did 
#general description also specifies English-only
Yeah but it applies everywhere else
It's primarily a reminder there bc it's the first place people will chat
Can we speak in Java?
Well considering Java is not a spoken language, sure.
System.out.println("Hi Spigot server");
When adding an attribute modifier (SPEED one) is this expected behaviour to multiple the attribute lore like this?
(its being added to a pickaxe)
Yes it's expected if you add it to all of those slots.
Javanese is spoken in java
Javanese lmao
It is the native language of more than 98 million people
right
Maow is a fun ruiner 
Weird as theres only one method for adding an attribute: im = ItemMeta
so javanese is good here
public class YamlTest {
Yaml yaml;
@BeforeEach
void setup() {
yaml = new Yaml();
}
@RepeatedTest(1_000)
void givenSingleQuote_doesThrow() {
var strToTest = """
test: '
""";
this.yaml.load(strToTest);
Assertions.assertTrue(true);
}
}
ooo
You define the slot in the modifier I think
I guess by default it's just all of them
@quaint mantle there it is
I'd say its probably a bad parser from the site you were using
@Test
void givenSingleQuote_doesThrow() {
var strToTest = """
test: '
""";
this.yaml.load(strToTest);
Assertions.assertTrue(true);
}
@Test
void givenSingleQuote_doesThrow0() {
var strToTest = """
test: 'text
""";
this.yaml.load(strToTest);
Assertions.assertTrue(true);
}
@Test
void givenSingleQuote_doesThrow1() {
var strToTest = """
test: text'
""";
this.yaml.load(strToTest);
Assertions.assertTrue(true);
}
the last one passes it seems like
but not the first or middle one
im gonna ask this again, whats the best way to update my config? should i pull out every value, reset, and replace the values?
truly
it possibly ignores it because its outside of a pair and does not contain anything
ye
and reset the values?
lets see if I add another node under
well
test: text'
test2: true
that still worked
mye
it just ignores it
in that case it treated it as a char
@Test
void givenSingleQuote_doesThrows() {
var strToTest = """
test: text' #comment
test2: true #comment
""";
this.yaml.load(strToTest);
Assertions.assertTrue(true);
}
passes
or well print?
https://github.com/tchristofferson/Config-Updater would this be any good?
possibly a special case for strings containing 's or s'
lets see
it has 40 stars
{dope: s'}
it keeps the quote
zacken
Yaml yaml = new Yaml();
Object load = yaml.load("""
dope: s'
""");
System.out.println(yaml.dump(load));
are we staill arguing over yaml lol
i would guess it will fail on nonstrings as its not an expected usage
ye lets see
how can i loop all the values in my config
did it put it in as a char?
well
config.getValues()
ye
hey so I have a schedulesyncrepeating task and I want to know how to cancel the task using a command
like /cancel
by specification parsers should recognize false and true as boolean values
you have to store the task id to some variable or data structure
keep a reference of the task (It's a BukkitTask object).
When you run the command, call BukkitTask#cancel
that doenst really mean much
^
true and false are just conventions
Timer = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
I have this as what I have. is that compatible to do what you just said
also I dont think it is what I am doing to code is wrong. I think its the fact that I am puting 2 commands in one class
they're more than conventions now, they have become the two canonical forms of representing a boolean value
is wrong
Yea that's in line with what I said. Now you just called Timer.cancel() whenever you want to cancel it
yes
well
ok
you wanna use runTaskTimer instead
as it gives you a BukkitTask instance as opposed to the one you're using now which provides a mere int
but the problem is that the thing wont work because the command doesnt work
mind sharing the command code?
sure
might simply be not canceling as a new one is created
public boolean onCommand1(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(commandLabel.equalsIgnoreCase("cpc")) {
Player player = (Player) sender;
if(!player.isOp()) return false;
else {
getServer().getScheduler().cancelTask(PlayClock);
i = 25;
for (Player players1 : Bukkit.getOnlinePlayers())
{
players1.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.RED + "PlayClock " + ChatColor.BOLD + "CANCELLED"));
players1.playSound(players1.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
}
}
}
return false;
}
what I had origannly instead of "timer" its playclock
lol
but now it is a duplicate method. do I have to put it in another class?
I didnt mean to put the 1 there though
?paste the classes perhaps
ok
well now my variables (that are public) wont work
maybe they will hold on
nvm they wont
I cant redifine the variable right
...
im new sorry
we really need to see what you are talking about
no worries, but having some basic understanding of Java's "grammar" and its concepts would help you a lot
yeah ik
If I have a variable. How would I use it in a different class?
without changing the properties of it
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ty
Usually you attach variable data to objects that you then pass around with (other) variables
oh ok
Hm
Probably the smartest beginner I've seen in here yet.
...and their profile is Shrek-themed.
insane minecraft enthusaist tho 😄
hardcore afk - must be a gens player
true dedication
hmm, why did i do this ... - java logic hurts my head
I am a minecraft sports player (dont judge)
judged
🧑⚖️
minecraft sports? - me looks that up
its pretty weird
but hey with my very bare bones knowledge they gave me 20 bucks to make a single plugin lmao
Placeholders.setPlaceholders() can be used on console?
how would i remove a single type of item from an inventory?
player.getInventory().remove()
declaration: package: org.bukkit.inventory, interface: Inventory
this one doesnt care abt that
why tf hasnt it been working for the past hour wtf
declaration: package: org.bukkit.inventory, interface: Inventory
this one should work for u
There is a guide to mysql?
it has lore stuff
then you need to find that item and remove it manually by setting its amount to 0
?mysql
you try the mysql website?
you should have a getMyCustomItemType(ItemStack) method for your plugins API if your implementing custom items correctly
yeah i really should
so i have to parse through each item in the inventory
clone it
set the amount of the clone to 1
why clone it?
dont clone if your trying to remove
im cloning the item so i can set the amount to 1
without messing up the original item
just loop -> check if its ur item, set to 0 if amt is equals than 1, else remove 1
^
im literally talking about how im gonna check if its my item
cloning is if you want to modify the item without actually changing it in the ivnentory
pdc
i cant just use .equals
?pdc
use a pdc tag
i do wanna do that
didnt you give it an id?
its to differentiate between regular and non regular items
so whats the problem...
so then its easy just loop through inv -> if item has tag -> set amount to 0
rust sems cool
lack of coffee!
but whats the diff between i32 and u32
int and unsigned
wat
A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295].
says IBM
LMAO
i do not fully recall but in most cases u32 should be an int. Might be a double though as well
I want to set the lore of an item such that it would display a players hunger, i mean not a number, with the logo of the eaten chicken
What would be the way to approach that?
a quick check says it being a double is not yet fully implemented
so you basically want a picture of a piece of chicken in your lore?
you'd need to use a runnable
oh you want a java mysql guide>
Haha no not a picture of a chicken , I mean like it shows when you are in survival
what
OHH
lmao
AttributeModifiers
😂
was about to say picture would be cool too
so if im making a money system for example
you can do it with Fonts
tf is an attributemodifier
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/attribute/AttributeModifier.html what does it do
declaration: package: org.bukkit.attribute, class: AttributeModifier
Allows you to modify attributes an an item without accessing NBT
ie
attack speed
are you issuing credit?
i think they want the item lore to show the player hunger
then yeah u32 makes sense
whast th efuck
I will look into that, thanks!
you will have to remember you are using unsigned in all your math functions though
i really need to comment my code
or like slightly optimise it so im not copypasting the same method over and over again with slight modifications
can you "hot swap" a world?
i mean, copying the world files without unloading it before hand?
I mean you can copy any file that's in use, afaik
I'm trying to create the modifier and I can't seem to find something that sets the hunger?
try it while streaming so we can watch!
will it be corrupted tho?
whats to corrupt if you moved the files?
good point
i just want to see if it generates randomly or burns up the server
Theoretically, would it be possible to load an unknown amount of commands from the config.yml?
You would be able to add as many as you want, each with a single string they will respond with
So the file would be like:
Commands:
command1: “Text response”
command2: “Text response 2”
sort of
Ok, thanks
That’s all I really needed before I wasted a bunch of time trying to do something that won’t work
commands.yml exists for a reason
doe anyone here use gradle, becuse i ran into an issue and cant find a soltuon
you still need to implement the commands
what problem?
Not my server, just been asked to make it so I am
basicly, i have two gradle modules,
I have a build.gradle in each module, a root level build.gradle, and a root level settings.gradle
I'm trying to import modulea into moduleb, i found a stackoverflow answer, but it didnt work and it seems to be outdated as it used stuff like compile and stuff, which doesnt even exist anymore
https://www.jetbrains.com/help/idea/project-module-dependencies-diagram.html you using this to check your dependancies?
Hey, how do you make Intellij IDE interact with minecraft? for example when I change something in the code and automatically applies to the server
setup a debug server
one second
thx, gonna look into this
alright, im gona check real quick
The section of it specific to gradle is: https://www.jetbrains.com/help/idea/work-with-gradle-dependency-diagram.html#gradle_generate
im on my laptop, i dont see an insert key xD
i see ins but its not doing anything
do you need to use your function key to access it?
ah one second
oh wow, yep thats works ^-^ i see the context menu
wow this is amaing, its just like NuGet
this is about the only easy-ish way to sort out interdependancies
ah no image perms
but i see a dependency search and my packages on the left, im not seing a way to add terminal into scratches
Its possible to do a server ping event through spigot to know if server is down or not?
sooo
errors and exceptions in java
are in rust but theyre called
Result::Errs
and Panics
nice
It's actually basically impossible to compare Java and Rust error-handling
panic is not a thing that can be properly handled (I believe you can listen to it but there's no way to prevent it)