#help-development
1 messages · Page 1638 of 1
player.setLevel();
Caused by: java.lang.ClassNotFoundException: net.maxicraft.capturetheclayplugin.minigame.EndReason
what
that class very well exists
it just decided for it not to exist
runtime
Caused by: java.util.zip.ZipException: ZipFile invalid LOC header (bad signature)
when i compile my pom.xml i get directed here, to this error. any idea how i can fix it?
pom.xml: https://pastebin.com/qvH0vqDB
error: https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot/1.17.1-R0.1-SNAPSHOT/maven-metadata.xml
Clean the projects, recompile all associated plugins, put them in and restart the server
[09:23:04] [Server thread/WARN]: at java.lang.Class.getDeclaredMethod(Unknown Source)
[09:23:04] [Server thread/WARN]: at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.getMethod(PlayerList.java:934)
[09:23:04] [Server thread/WARN]: at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.invokeMethod(PlayerList.java:804)
[09:23:04] [Server thread/WARN]: at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.invokeMethod(PlayerList.java:781)
[09:23:04] [Server thread/WARN]: at vinnydgf.deangroup.bukkit.listener.PlayerList$1.callBack(PlayerList.java:513)
[09:23:04] [Server thread/WARN]: at vinnydgf.deangroup.bukkit.listener.Skin$3$1.run(PlayerList.java:1129)
[09:23:04] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:64)
@Override
public void callBack(Skin skin, boolean successful, Exception exception) {
Object profile = GAMEPROFILECLASS.cast(ReflectionUtil.invokeMethod(data, "a", new Class[0]));
if (successful) {
try {
Object map = ReflectionUtil.invokeMethod(profile, "getProperties", new Class[0]);
if (skin.getBase64() != null && skin.getSignedBase64() != null) {
if (!ReflectionUtil.isVersionHigherThan(1, 13)) {
ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { String.class },
"textures");
} else {
ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { Object.class },
"textures");```
How would I setup a gradle kotlin and Java project?
Package names/class locations changed in future versions
I need some help in tying the World to the namespaced key that Minecraft uses. I do not currently see a way to link them. World.getName() isn't it, the closest I could see is World.Environment.... which uses NORMAL, NETHER, THE_END. So... I tried to create an EnumMap to handle manually tying them together. It used to work flawlessly, and now that I've pulled it out into a separate plugin, I am getting null values:
public enum Dimension {
OVERWORLD(World.Environment.NORMAL,"minecraft:overworld"),
NETHER(World.Environment.NETHER,"minecraft:the_nether"),
END(World.Environment.THE_END,"minecraft:the_end");
private final String namespace;
private final World.Environment environment;
private static final Map<World.Environment, String> byEnvironment = new EnumMap<World.Environment, String>(World.Environment.class);
static {
for(Dimension d : values()) {
byEnvironment.put(d.environment, d.namespace);
}
}
private Dimension (World.Environment environment, String namespace) {
this.namespace = namespace;
this.environment = environment;
}
public static String getNamespace(Location location) {
return byEnvironment.get(location.getWorld().getEnvironment());
}
}
if there is a better way to do this, I'd be happy to hear it. I just couldn't seem to get that info with Spigot. PaperMC downstream has a getKey() off of world which may work, but I was trying to stay upstream.
isn't the namespace for nether just minecraft:nether and not minecraft:the_nether
What are the null values?
I have a task that gets a location and calls Dimension.getNamespace(location); returns null
The autocomplete for /execute in shows minecraft:the_nether
I maybe reading it wrong but the for loop namespace would be null when its first ran wouldn't it?
It's an enum, so the fields would have already been instantiated.
Try debugging it then.
... I suppose you get a lot of people in here who don't do that first, but I have and use Discord as a last resort.
What’s the issue
The values are coming back as null
What values specifically:0
1.16.5 there is no getView, getName or getTitle for e.getClickedInventory in Inventory Click Event what do i do
Why not do everything inside?
I just tested your class it seems to be working fine for me... Are you sure the location isn't null?
Yes.
static {
Map<K,V> map = EnumMap.noneOf(K.class);
Arrays.asList(K.values()).forEach(e -> {
map.put(...);
});
byEnvironment = map;
}
There is some odd race condition with that static block. and to @ivory sleet's point, I didn't want to have to have an instantiated reference of the class, so enum made sense, but that I would have to do it statically
1.16.5 there is no getView, getName or getTitle for e.getClickedInventory in Inventory Click Event what do i do
I just tried a different implementation:
public class Dimension {
private static final Map<World.Environment, String> byEnvironment = new EnumMap<World.Environment, String>(World.Environment.class);
static {
byEnvironment.put(World.Environment.NORMAL, "minecraft:overworld");
byEnvironment.put(World.Environment.NETHER, "minecraft:the_nether");
byEnvironment.put(World.Environment.THE_END, "minecraft:the_end");
}
public static String getNamespace(Location location) {
return byEnvironment.get(location.getWorld().getEnvironment());
}
}
Still the byEnvironment enumMap is empty
Hmm yeah thats odd
public static String getNamespace(Location location) {
if(byEnvironment.isEmpty()) {
byEnvironment.put(World.Environment.NORMAL, "minecraft:overworld");
byEnvironment.put(World.Environment.NETHER, "minecraft:the_nether");
byEnvironment.put(World.Environment.THE_END, "minecraft:the_end");
}
return byEnvironment.get(location.getWorld().getEnvironment());
}
```Try this for the hell of it
Yeah for the record are you doing this on the main thread or not?
yes, main thread
Then yapperyaps lazy initialization should work
My only guess is that static clauses are called when the class is first referenced, so maybe since you're first referencing it with a another static method, the method fires, and then the static clause is called after? 
Are you running new Dimension() every time you try to get the namespace?
Yeah cause Enum maps are not thread safe by default
So yes, adding to the map in the static method did work. I would probably throw my computer out if it didn't
Seems, dirty, but whatever this only exists because it's dirty
Thank you for your help @ivory sleet .
Thank the others also but nice you solved it
Yeah, I hit enter too quickly, I was trying to tag @stone sinew as well.
Thank you
Alrighty cool
I didn't do much but you're welcome lol
I have a tpData.json file but does anyone know how I can get my reader to use it without the absolute path?
Reader reader = Files.newBufferedReader(Paths.get("C:\\Users\\gaela\\IdeaProjects\\AdvancedChorusFruit\\src\\main\\java\\me\\jiovannyalejos\\advancedchorusfruit\\tpData.json"));
I'm trying to find a way so that it'd work without an absolute path so probably a relative path or smt, so that others could also use it
Had to look at one of my discord bots to find that xD
x)
Does anyone know how to add custom entry fees for Portals?
hmm so like would this work?
Reader reader = Files.newBufferedReader(Paths.get(".\\AdvancedChorusFruit\\src\\main\\java\\me\\jiovannyalejos\\advancedchorusfruit\\tpData.json"));
?
Obviously that code of yours can’t be production ready
it's in a listener class that reads the tpdata file so it knows where to teleport the player
w-wait wdym?
You’re running a server in your dev workspace src folder?
no, i'm running it in a separate folder and the plugin is just in the plugins folder in the same directory as the server
or as the server startup jar
I’m confused but I guess, isn’t that path wrong then?
wait, how so?
Usually data is stored in plugin folders
Not in the java source folder of your work space
If you want the datafolder of your plugin just run JavaPlugin.getDataFolder()
wha- sry i'm just learning some new things rn, so the getdatafolder() would get it in which directory? and could it get the json file if i move it there?
Yes
What ever the name of your plugin is... so plugins/<pluginName>
whats the difference between Bukkit.getPluginManager().isPluginEnabled() and getServer().getPluginManager().isPluginEnabled()?
Bukkit.getPluginManager().disablePlugin(this);
Does that in the main class disable the plugin?
so that would be in this dir, right? but i don't see it i think
Just api instance. getServer() or Bukkit.
Should be able to drag and drop the file into your compiler. I thought you were talking about getting the plugin folder for your plugin
th-the compiler?
your ide...
ohh, i thought you meant the thing that turns the readable code to macine code
i think-
unless you meant smt different-
No you're right. Just drag and drop the file where you want it to be saved in your project
ahh ok
Static call vs instance call
If we talk about unit testing the instance call is better
Even when we talk about object orientation
There might be a reason that more than one server instance exist at the same time which the Bukkit class obviously wouldn’t be capable of handling however in a spigot plugin context using the Bukkit class is probably benefiting since it’s less verbose.
So you made me realize something, this is the directory to my json file that's being used in my ide but not for the one that would be in my compiled jar file....
Reader reader = Files.newBufferedReader(Paths.get("./src/main/resources/TeleportData.json"));
but to get it from the plugin folder, i have to use JavaPlugin.getDataFolder() which would be the resources folder? but then the "./src/main/resources/TeleportData.json" bit wouldn't make sense I think, and there's a plugin.yml file in resources as well, so how do i specify?
How could I check if a player sent 3 or more messages in the last 5 seconds?
I made a player cache, I figured I would log chat messages but I can't seem to find a way to know when they were sent nor when to delete that data to limit ram usage
When you put the file in your project you would use getResource("file").getBufferedReader() since you will be getting the file from your jar.
just save the time of player messages using System.currentTime()
If the list of times has more then 3 remove the first (the one further from the current time)
so getResource is a method in the Javaplugin class so I have to use it in my main (?) so i assume i have to use
File TeleportData = new File(getResource("TeleportData.json").getBufferedReader());
as a variable that i can get in my listener class?
but the getBuffered reader doesn't seem to be a method i could use, since it isn't showing up(?;-;?)
Bukkit.getPlayerExact(args[0]) == null && Bukkit.getOfflinePlayer(args[0]) == null
Is this true if args[0] is the name of a non existing Player?
Or just make an instance of your main class accessible by other classes.
My bad getResource is an input stream so you have to cast it to buffer reader.
InputStream infoFile = getResource("file");
BufferedReader info = new BufferedReader(new InputStreamReader(infoFile));
If a player with the username specified has never joined the server it should return true. (I could be wrong though)
I'll test it
welp it always returns false
if he hasnt joined and if he doesnt exist
👍
How would I check if a player name simply exists? Without the UUID?
You would have to check the mojang api
there's no other way?
No the server can only tell you playernames that have joined.
okay
sorry, i took a bit since i had to do a chore, so the path would be something along this line?
Reader reader = Files.newBufferedReader(Paths.get(new AdvancedChorusFruit().info));
which i feel is almost what i'm supposed to do...
toString would not return the path right?
new AdvancedChorusFruit() is a class. not a path.
Show the code you have currently where you are trying to get a reader
wait, what's the difference between an instance of my class and an object of it again...
oh, ok
it's in my PlayerTeleportEvent listener class
Instance is something accessible you save like a variable.
ohhhh
?paste
InputStream infoFile = getResource("TeleportData.json");
public static BufferedReader info = new BufferedReader(new InputStreamReader(infoFile));
so i'd do this in main and then just get it in the Paths.get() except getting the path first(??)
Add the file to your project like this then use the above code to access the file within your plugin.
the- the first line has an error warning when i try to make it static
Non-static method 'getResource(java.lang.String)' cannot be referenced from a static context
in your main class add
private static <ClassName> instance;
public void onEnable() {
instance = this;
}
public static <ClassName> getInstance() {
return instance;
}
```If you need to get a variable or such from your main class just use `<ClassName>.getInstance()`
ohh, that's actually pretty smart
how to get the current UNIX timestamp?
System.currentTimeMillis()
thats not the unix timestamp
My bad maybe use Date
Is it this maybe?
System.currentTimeMillis() / 1000L
just remove the milliseconds?
Date date = new Date();
date.getTime();
So i feel like i'm very close, but i'm not sure how to get the file path of info, which, i'm not exactly sure what the BufferedReader type object is so i'm not sure if i actually need the path still
Reader reader = Files.newBufferedReader(Paths.get(AdvancedChorusFruit.getInstance().info));
Did you add the file to your project?
i did
screen shot
InputStream infoFile = <ClassName>.getInstance().getResource("TeleportData.json");
public BufferedReader info = new BufferedReader(new InputStreamReader(infoFile));
CoordinateData data = gson.fromJson(reader, CoordinateData.class);
if(data.locNames.contains(itemDisplayName.substring(5))) {
String[] coords = data.coordinates.get(data.locNames.indexOf(itemDisplayName.substring(5))).split(Pattern.quote("|"));
event.setTo(new Location(player.getWorld(), Double.parseDouble(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2])));
reader.close();
}
wh-
oh
oh ok i thought all that was new
ohh, so i only needed the class instance and not have the inputstreamstuff in it
How do I get the timezone the server is in?
In the format "GMT-4" for example
nvm
my simple explosive bow isn't creating an explosion at the arrow location? ```java
@EventHandler
public void bowShoot(ProjectileHitEvent e) {
Player p = (Player) e.getEntity().getShooter();
assert p != null;
if (p.getInventory().contains(arrow())) {
if (p.getInventory().getItemInMainHand() == bow()) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1, false);
e.getEntity().getWorld().playEffect(e.getEntity().getLocation(), Effect.WITHER_BREAK_BLOCK, 1);
e.getEntity().remove();
}
}
}```
??? getResource() is an input stream. BufferedReader takes an InputStreamReader.
- player can swap items before arrow lands.
- Bows take the arrow from the players inventory.
just testing the bow atm
Question: what is the best method for making your commands autocomplete?
why isn't the bow working?
Ohhh ok, but thank you, it works perfectly now :)
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {} and register it like a command... getCommand("cmd").setTabCompleter(TabCompleter);
public class <ClassName> implements CommandExecutor, TabCompleter
wait, i meant that the inputstream stuff was in my main as variables when it didnt need to be also
What do you mean? Not working how?
the explosion is not created at the arrow location
Oh you said the bow in the last message.
Debug it check if its actually being ran.
alright
And remember you're using ProjectileLandEvent not ProjectileLaunchEvent (I say this because the method is named bowShoot)
How do I essentially cancel the PlayerJoinEvent? Or prevent them from joining
player.kick(String)
simply that on joinevent?
and it doesnt cause any interference with other joinevents?
What is the check with vault to see if an OfflinePlayer has a specific permission?
what would be the most efficient way
to find all the possible spawns in skywars
like
how do i iterate through all the blocks
and find all the locations
in the glass cages
or do i have to manually enter them in
just save the locations?
Hello! What difference between getBlock() and getBlockPlaced() in BlockPlaceEvent?
Have a method to get all the blocks in a pattern and the parameters will be the 1 or 2 blocks of air in the middle
im thinking of adding a /addspawn
it literally just adds a spawn at ur location in a config
then when the game starts it iterates through all of them, adds em to a list
Why would you do that when you can just store the spawn locations themselves?
Anyone know?
It works by using
AsyncPlayerPreLoginEvent
and
.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "")
Hey y'all!
Is there a way to store data in an items's PersistentDataContainer as an ItemStack?
how
do i get this
Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
and make it a location object
Well yeah lol... but you said PlayerJoinEvent
I can try, no promises
a
Well looks like a json string so just parse it using json... JSONObject data = (JSONObject) new JSONParser().parse(String);
im trying to convert it to a location
yeah parse as json then use the out put... data.get("x") and make a location
ok
My bad Location has serialize and deserialize methods. Just deserialize it.
oh, how?
i did location.tostring
and im retreiving a list<String> from my config of all the locations
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Where are you putting the location that you need .toString() then?
spawns:
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=-43.5,y=73.0,z=0.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=-14.5,pitch=0,yaw=360}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=-42.5,pitch=-0,yaw=-360}
- Location{world=CraftWorld{name=world},x=-13.5,y=73.0,z=-28.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=14.5,y=73.0,z=-28.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=-14.5,pitch=0,yaw=-360}
- Location{world=CraftWorld{name=world},x=44.5,y=73.0,z=0.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=15.5,y=73.0,z=29.5,pitch=0,yaw=90}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=44.5,pitch=0,yaw=180}
- Location{world=CraftWorld{name=world},x=-14.5,y=73.0,z=29.5,pitch=0,yaw=270}
thats what my list looks like
i want to turn that into a list of locations
Why not just create your own string of the location then so its easier to grab?
public String locationToString(Location loc) {
return loc.getWorld().getName()+","+loc.getX()+","+loc.getY()+","+loc.getZ()","+loc.getYaw()+","+loc.getPitch();
}
public Location stringToLocation(String string) {
String[] data = string.split(",");
return new Location(Bukkit.getWorld(data[0]), Double.valueOf(data[1]), Double.valueOf(data[2]), Double.valueOf(data[3]),
(float) Double.valueOf(data[4]), (float) Double.valueOf(data[5]))
}
because i already made all the locations and i do not want to do it again
12
Then gotta json parse it Like I said above.
okay
Locations are already serializable, you can literally put the list into the config with one line of code
He wants to get them from config not add to it.
yes, once added they are auto serialized, which means you can easily retrieve them
No.... he already has them listed... he wants to convert his already made config to locations not add to the config
Those are simple toString() of Locations, so he has them in code already
its 10 seconds to output in teh correct format
i'm pretty sure you can fetch from json as a raw object then try casting it to Location
ok so i deleted this bc i thought i figured it out but i was wrong-
this code:
https://paste.md-5.net/juwuzimuno.cs
spits out this error:
https://paste.md-5.net/cugegewefi.cs
for this table:
UUID | MANA | MAXMANA | MANA_REGEN
| 0 | 0 | 0
| 0 | 0 | 0```
any idea why? I get its trying to say theres no MANAREGEN in the table which is right but I dont mention MANAREGEN, I mention MANA_REGEN. Line 159 is ``ps.executeUpdate()``
That’s strange because underscores are perfectly legal for table names.
Give that a go and see if it makes a difference.
Do you have the full code snippet?
uhhh sure
but I've just changed it to not have the underscore
well
for some reason that fixed it?
Yeah that is bizarre
oop
but
the code only runs on first join and when I joined a 2nd time
now theres 2 of my uuid and stats
here's my full code
yup
it also doesn't update when i leave?
in your schema set your UUID column as a primary key/unique
im sorry this is my first time using SQL what does that mean-
you should declare your tables' schema that uuid is your primary key
what SQL db are you using
wait-
im using phpMyAdmin for my db
i think thats what you're asking? But if you dont know its a MySQL database
if thats what you're asking
i'm so sorry i'm not very knowledgeable in mysql stuff haha
I mean MySQL haha
alright cool
phpMyAdmin is just a software helping you manipulate the sql database
is there any way to disable firecharge (projectile) from exploding and setting fire
swag
https://bukkit.org/threads/disable-explosion-fire-from-fire-charge-projectile.223356/ idk if this would help but basically get the fireball that's launched when a fireball is launched then setIsIncendiary(false);
public HashMap<String, String> PlayerGuilds = new HashMap<String, String>();
public void UpdatePlayerGuilds(String player, String guildName) {
PlayerGuilds.put(player, guildName);
}
UpdatePlayerGuilds is called from a seperate class like this
PlayerGuildData playerGuildData = new PlayerGuildData();
playerGuildData.UpdatePlayerGuilds(player.getName(), "test");
the problem is that the hash map doesn't save. when this function is called
public String GetPlayerGuild(String player) {
if (PlayerGuilds.get(player) != null) {
return PlayerGuilds.get(player);
}
return "Error - Player is not in a guild";
}
Error - Player is not in a guild is returned because PlayerGuilds.get(player) is null.
so why doesnt the hash map save?
pls use camelCase 🥲
but uh
are you reloading after running the update method
are you restarting
Dont make data structures public. Make them private final and write accessors for them.
Next: Never use a players name for identification because a minecraft name can be changed. Use the players UUID.
We need more infos. You probably have multiple instances of the class that contains the "PlayerGuilds" map.
Also: Nothing in memory is saved. If the server shuts down then you start with new, clean instances.
If you want to persist data over restarts you need to write the data onto your disk.
If your DB is busy while a player connects then you produce massive lag. If a connection starts hanging then your server just crashes.
hmm?
so like \
basically the situation is
on first join it adds them to the thingy
and saves when they leave
would that still produce alot of lag often?
bc itd be used in those situations
Events are executed on the main thread. If you connect to a database in an event and the connection starts hanging then you block the whole server. If this lasts several seconds then the server just crashes.
ahhh
whats a better way to do this then?
also i've changed my code
idk how much it helps but
can a World object change somehow? besides deleting it. is it safe to use it as a map key?
Worlds have UUIDs which should be used. You can use a World object but if you are not careful then you will end up with a massive memory leak.
Connections to databases should always be done async.
In your case you should just use the AsyncPlayerPreLoginEvent and fetch your DB data in there.
ahhh ok
ok but then how do I get the event player?
i see event.getUniqueId
but i'd have to change alot of stuff for that to work
You dont.
If the user is not in the DB then just set default values.
alright cool
why does mojang still uses this very old mechanic and uses the single-thread server, is there a way to change that using a plugin or something in spigot?
lol no. Almost every game has a main thread. Also this is deeply rooted within minecrafts code. You would need to completely re-write the entire game from ground up in order to introduce proper multi threading.
but isn't the single-thread thing annoying
is there any async quit event? I cant find anything so I'm assuming no
but i figured i'd try my luck haha
Guys. Help. I want to summon a falling block and teleport it wherever the player looks
Quick question: should I create a MySQL table for each part of my plugin, or join a few together and have a few seperate. e.g Do I create a table called 'playerdata' which can store their friends, their balance, profile info etc, or do I have one table for friends, one table for economy, etc
Nope. Just spawn a new thread
yup! just figured it out but thanks for the reply
appreciate people like you alot smile, helping people out just to help :)
Could you elaborate a bit more?
my system just has a 'playerdata' table system but i'd say it depends on the complexity
If you want to have one centralised data structure then a relational database is a bad idea. Relational databases are made for relational data. So one table for every new type of data that has a relation to a user.
hangon wait no it doesnt make sense :P
so should I make a new table for every new type of data or not
If you want to use a relational database then yes. You should make a new table for different types of data.
But it also depends on the scope of your project.
If your plugin is a monolith that is used to run a server then you should def split up your data. If you only provide a plugin for others to use then you can get away with just one table containing all your player data.
It's going to be used to run the core aspects of a server so sounds like splitting it up is the way to go
tysm for the clarification
once again cheers :)
Unexpected character (L) at position 0.
JSONParser parser = new JSONParser();
JSONObject data = (JSONObject) parser.parse(s);```
help plz
s is valid json
i think
Jackson?
unless this isnt json
Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
This isnt json
what is it then
i did Location.toString() how do i do something like Location.fromString()
lol
idk lol
Where do you want to store the location. In a yml file?
yes
Then just throw it in. Location already implements ConfigurationSerializable.
wdym
its in a string list
if i throw an exception, i dont have to return to stop the code execution, right?
Yes. But in some cases its a good idea to manually handle the exception.
Or do you mean you throw a new exception yourself.
Also another question: can I/how can I store lists in a MySQL table?
(Friends list)
i throw the new exception myself
Then the code execution stops right there.
Serialize one Location
YamlConfiguration configuration;
Location location;
configuration.set("SomeLocation", location);
Deserialize one Location
final YamlConfiguration configuration;
final Location location = configuration.getLocation("SomeLocation");
Serialize a List of Locations
YamlConfiguration configuration;
List<Location> locationList;
configuration.set("ABunchOfLocations", locationList);
Deserialize a List of Locations
final YamlConfiguration configuration;
final List<Location> locationList = (List<Location>) configuration.getList("ABunchOfLocations");
is this getting or setting
oh okay lol
hopefully this works >.<
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.bukkit.Location (java.lang.String is in module java.base of loader 'bootstrap'; org.bukkit.Location is in unnamed module of loader 'app')
Dont throw in a List<String>
spawns:
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=-43.5,y=73.0,z=0.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=-14.5,pitch=0,yaw=360}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=-42.5,pitch=-0,yaw=-360}
- Location{world=CraftWorld{name=world},x=-13.5,y=73.0,z=-28.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=14.5,y=73.0,z=-28.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=-14.5,pitch=0,yaw=-360}
- Location{world=CraftWorld{name=world},x=44.5,y=73.0,z=0.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=15.5,y=73.0,z=29.5,pitch=0,yaw=90}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=44.5,pitch=0,yaw=180}
- Location{world=CraftWorld{name=world},x=-14.5,y=73.0,z=29.5,pitch=0,yaw=270}```
thats my ymal
yaml
Why need to be cloned? https://ibb.co/xsJfHm2 <-- image
what do i do then
Look at the examples form above.
More context pls.
In image
okay
More context to the image pls
Item#ItemMeta(), it return a cloned item meta
Why don't just not clone, then we no need to Item#setItemMeta() when set
Yes. But we need more context or else we cant say if it makes sense or not. Generally you dont want to clone objects unless you want to provide immutablity.
Ah i see. So the context is: This is spigot source code
World#getBlockAt() is not cloned
Changes to the ItemMeta would not be reflected to the NMS ItemStack anyways. So making it immutable makes it more clear.
Yes, but I want to know why, the reason need to be cloned
Ohh 🤔
Because ItemMeta has no direct handle like Block has.
Its an abstract model introduced by spigot
Then, they update the item when applying item meta? Ok!
You could make changes to the NMS ItemStack every time the ItemMeta changes. But that would be way more expensive than just applying all changes in bulk once.
So spigot (or rather bukkit) opted for this approach.
Ok thank you!
i have an item when you right click blocks with it, the block turns into a falling block and teleports itself 5 blocks from your eye location
the code
it just breaks the block
no falling block entity
Do you want it to be exactly 5 units away at all times or on top of the Block the player is looking at?
at all times
This code will cause lags really fast. You will have thousands of runnables stacked up in no time.
Ill write you an approach
Dont
Where do you want to store the ItemStack?
works, tysm
ItemStack implement ConfigurationSerializable.
So you should try to serialize/deserialize the class using those methods. Try putting the Map<> returned by ItemStack#serialize() into Gson
Might work
Doesnt work...
Does it need to be readable? Or can it also just be a Base64 String?
Ill just give you my methods. You need NMS on your classpath for this to work:
public static String serialize(final ItemStack itemStack) {
final NBTTagCompound tag = new NBTTagCompound();
CraftItemStack.asNMSCopy(itemStack).save(tag);
return tag.toString();
}
public static ItemStack deserializeItemStack(final String string) {
if (string == null || string.equals("empty")) {
return null;
}
try {
final NBTTagCompound comp = MojangsonParser.parse(string);
final net.minecraft.world.item.ItemStack cis = net.minecraft.world.item.ItemStack.a(comp);
return CraftItemStack.asBukkitCopy(cis);
} catch (final CommandSyntaxException ex) {
ex.printStackTrace();
}
return null;
}
@lost matrix btw
is it fine if i dont understand any shit in nms
its all random letters and shit
wait… does the serialize method not work?
In 1.17 its all obfuscated. You need to apply the mojang mappings in order to understand anything in there. I could just extrapolate on previous versions because i have been digging in NMS for a while so i can find out what methods/filds do/mean
just by looking at return types and patterns etc. But if you want to properly understand whats written there you can just apply moj mappings
It does work but i couldnt figure out how to deserialize it again. The resulting ItemStack lost all metadata.
aaaa ok
oh balls
i’m using that atm
will have to have a look
you can just base64 it right? i seem to remember that being a thing
final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
final ItemStack itemStack = new ItemStack(Material.DIAMOND_AXE);
final ItemMeta meta = itemStack.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.setDisplayName("§eCool Axe");
meta.addEnchant(Enchantment.ARROW_DAMAGE, 3, true);
itemStack.setItemMeta(meta);
System.out.println("Item: " + itemStack);
System.out.println("------------------------------------");
final String json = gson.toJson(itemStack.serialize());
System.out.println(json);
System.out.println("------------------------------------");
final ItemStack deserializedItem = ItemStack.deserialize((Map<String, Object>) gson.fromJson(json, Map.class));
System.out.println("Item: " + deserializedItem);
final String json2 = gson.toJson(deserializedItem.serialize());
System.out.println(json2);
Made:
Item: ItemStack{DIAMOND_AXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"yellow","text":"Cool Axe"}],"text":""}, enchants={ARROW_DAMAGE=3}, ItemFlags=[HIDE_ATTRIBUTES]}}
to
Item: ItemStack{DIAMOND_AXE x 1}
One could probably figure out whats wrong but i didnt really bother
myeah
hi me again uhmm
ive been struggling with this for about an hour and I just can't get it so-
Where are the mojang mappings?
im trying to update a player's stats
Main.prepareStatement("UPDATE playerinfo SET MANA = '100', MAXMANA = '100', MANAREGEN = '2' WHERE UUID = '" + player.getUniqueId() + "'").executeUpdate(); doesn't work
Read all of this:
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
oh god ok
yeah it talks about the buildtools command
java.sql.SQLException: No value specified for parameter 1
wait-
let me try something
yeah no that didn't work
I'm just extremely confused and lost and in need of resources or just assistance
Show us some more code pls.
What do you want to achieve?
Ok. So for saving you probably want to upsert.
Upsert means -> Insert but if key exists then update
but ig I could just have it do the actually variables? idk why I hardcoded it
well I’m sorry but just shut ur trap then would u
alright! thanks will look into it
sheesh so annoying
much appreciated thank you smile
Happy now 🙂
id like to share
that the issue that I was struggling with for 2 hours was because I had this line of code
final static String INSERT_QUERY = "INSERT INTO playerinfo (UUID,MANA,MAXMANA,MANAREGEN) values(?,?,?,?)";
lol
thought that was funny
anyways
Just pipe a BukkitObjectOutputStream into a byte[] and let it be encoded in Bas64
ok
Something like this:
public static String itemStackToBase64(final ItemStack item) {
final String line;
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream)) {
dataOutput.writeObject(item);
line = Base64Coder.encodeLines(outputStream.toByteArray());
} catch (final IOException e) {
e.printStackTrace();
return null;
}
return line;
}
thanks
saved me from stack overflow 
what is the best way to get back to ItemStack
cause the ItemStack#deserialise takes a map
not b64
the bukkit object input stream ? 😅
myea
but how do i get object from it
final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
damm
im dumb
I think ObjectInputStream#readObject
uh alright
read the messages before that
i have an item when you right click blocks with it, the block turns into a falling block and teleports itself 5 blocks from your eye location
https://paste.md-5.net/amonaqajew.java
the code
it just breaks the block
no falling block entity
help
help
This plugin will be quite hard to write as the movement of falling blacks doesnt seem fully server authoritative:
you could do it better with command blocks
You need to do that with packets and some NMS
but i've seen it smoother with command blocks at least
yeah this is probably your best bet
Let me try a quick setup
Why would command blocks Change anything?
im not really good with command blocks but
it goes off 2 ideas
- I've seen command blocks do a good job with this exact thing
- I trust smile's statement that the falling block option wouldn't work the way it's desired
but the command block option presents issues for server side things
They (the commands) are not sent to the client
mhm
So If it works with command blocks it will also work with plugins
probably
i feel like you could turn off gravity for falling blocks?
turning off gravity prevents an entities velocity from being applied tho
it is a shitty system
huh
can you just send the code you are using right now? i can just modify it.
well i want to throw the block, but i can easily turn it on again when i try to throw it
yeah
This seems to work and is packet based so the falling block doesnt get ticked.
Is there any way to get nearby tileentities?
:0 this is really smooth
do you guys mind if I nab it? (Core and Smile)
Alright, can you send the code?
if not totally understandable
bc its your project and your idea and your code
but i figured why not ask haha
well its for my WIP minecraft server. but since its WIP, sure
cool!
if smile ever sends the code to me
haha
ill let you nab some of my code sometime but I dont have much to offer
This is just a proof of concept and should not be used in a plugin:
https://gist.github.com/Flo0/89c239f0de52ddf3f2808db8bf409235
Sure go ahead.
great!
do you know a good one?
Bukkit.getScheduler().runTaskTimer(this, this, 1, 1); gives out an error
Cannot resolve method 'runTaskTimer(works.net.Worksnet, works.net.Worksnet, int, int)'
i am using intellij
fixed it
cannot deserialize a location or something :/
https://paste.md-5.net/qogafavuko.sql
you are loading locations before the world are loaded
owh
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§c100 / 100"));```
and for some reason this also isnt working
In which context?
Hello! Why is this cause?
[12:10:20 WARN]: Player SivannGaming just tried to change non-editable sign
how can i set the velocity of EntityFallingBlock?
.setVelocity() ?
probably cast it to something
tried
Hey guys, help me please
Wondering if i can put EntityType enum in broadcastMessage() parentheses, will it convert automatically or should i use .name()?
it will automatically run toString()
Ok thanks
if you do something like (EntityType.WHATEVER + "")
that might not be the same as .name() however so be careful
Can it cause an internal irror?
What does EntityType return?
ingame
If it returns a string then go for it, but I feel it does not
So you’d need to use .name
entity type is an enum not a function, it doesn't return anything :?
Oh yea shit
🙂
I just woke up leave me be 😂🤣
@Getter @Setter lol
I'm trying to cast from MCUTeam to DecisionDomeTeam. DecisionDomeTeam extends MCUTeam
WhAt Is LoMbOk?
because it is not an insnace of decisiondome
I'm not trying to cast to DecisionDome
ddt
I'm trying to cast to DecisionDomeTeam which extends MCUTeam
yk what i meant
oh right
oh so I can't cast like that
no
ugh
guys if i do that if statement do i need ((LivingEntity) entity)?
i suppose the sethealth method is a member of livingentity, so yes
what do I do instead then? I have a bunch of minigames, through which the teams earn points across
for each game I want to store information about each team, but I don't want to put that information in the team class as it's only used for the one minigame
i mean this code doesn't run if the entity is not livingentity
yes but the sethealth method is defined by the livingentity class so you must cast it to use it
Ok thanks
i am going to take a wild guess and say you're a fan of MCC? @supple elk
sounds very MCC inspired
?paste
https://paste.md-5.net/yorajarima.coffeescript tryinna add velocity to a nms entity. its supposed to boost em up wherever i look at but no. wont work.
stays still at air
I'm trying to use the API to return a plugins version on my website but it's failing the connection
However it works with other PHP fiels
I'm setting a persistent data to a tileentity, but it does not set (whenever i check it on other events it does not have data that I've set)
@EventHandler
public void onPlace(BlockPlaceEvent event){
if (!isBeaconBlocker(event.getItemInHand())) return;
new Area(event.getBlockPlaced().getLocation(), radius);
TileState state = (TileState) event.getBlockPlaced().getState();
state.getPersistentDataContainer().set(Main.beaconKey, PersistentDataType.INTEGER, 1);
System.out.println(state.getPersistentDataContainer().getKeys());
MessageUtils.sendMessage(Main.getInstance().getConfig().getString("messages.blocker-placed"), event.getPlayer());
}```
Anything i missed?
Not
PHP
Oh, i did not do state.update()
Solved
Where else do I put api questions?
how can I check if a player has any inventory open?
some php discord
?
player.getOpenInventory()
send code
My php code works fine but cannot connect to the spigot api
?paste
that can't be null?
Gets the inventory view the player is currently viewing. If they do not have an inventory window open, it returns their internal crafting view.
Yes
How can I sort a list of this class in order of sheep from highest to lowest
Check if it's not their internal crafting view
isn't the internal crafting view the players own inv?
It is
🤔
Opening player inventory does not event fire an event
So i guess it's client-sided
Yes I tried InventoryOpenEvent & InventoryCloseEvent event It didnt fire
Hello i'm trying to send two PacketPlayOutNamedEntitySpawn with same UUID in the GameProfile for spawn two NPC with same skin but just one is visible, someone know about this probleme ?
player.getOpenInventory() != null
player.getOpenInventory().getType() == InventoryType.PLAYER ig
maybe because it runs through the for loops b4 reaching your if(change) part?
yes but it's not like I set it false again
these events are spaced out
each change set true you can see in that screenshot is an entirely different run over of the for loop
anyway I fixed it by using an atomic
bcs you declared the variable in the same scope
why would that be a problem?
when the scope is called again, you'll have the variable false again
can y'all help me, please?
Which NMS version are you using?
how does that work?
I know it resets to false every time, that's the point
the problem is that I run code immediately after setting it to true
but for some reason it's been set to false again before that
1.17.1
I check immediately after it's set to true before it should have the chance to be set back to false
which event was being called from?
the event works but the part i shared doesnt
it just
stuck midair
gravity is on for the falling block btw
is this something?
public class ActionBar extends BukkitRunnable {
private final Player player;
private final String text;
private final int seconds;
private int start = 0;
public ActionBar(Player player, String text, int seconds) {
this.player = player;
this.text = text;
this.seconds = seconds;
}
@Override
public void run() {
start++;
Utils.sendActionBar(player, text);
if (start == seconds) cancel();
}
}
u want to send action bar?
Likely
yes
?stash
for some reason this wont work
TextComponent component = new TextComponent();
component.setText(message);
component.setColor(color);
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, component);
Alternatively use something like that, that should work 100%
help me please
What problem do you have?
explained it
replied to it i mean
https://paste.md-5.net/yorajarima.coffeescript tryinna add velocity to a nms entity. its supposed to boost em up wherever i look at but no. wont work.
i also tried to add fallingBlock.show()
but it just made it dissapear
wait
i am trying something
The StaticFallingBlock class is completely packet based. That means setting the velocity of it wont cause the Block which is shown to a user to fly because the user doesnt receive the movement packets.
Also, the velocity is set using the setMot() method
now i can drop the block
but not give it velocity
and the falling block just stays there
not turning into a block
Because its not actually there. The client only thinks its there.
The server doesnt know the block exists so it wont turn it into a block.
Nope
?paste
Im also not sure if the packet approach is good here. You should probably just spawn a FallingBlock with velocity turned off and overwritten move() or tick() method to make it teleport to the users crosshair,
Then this might be a very hard project for you.
i like to challenge myself though
what do i have to do here?
Eh. You can get creative with this.
Actually spawn the block in or do a bunch of logic yourself.
Spawn the block in and overwrite some stuff so it does what you want it to do idk
is there also something to edit the text of an actionbar?
What do you mean by "edit"?
hi
change the text after it has been sent
like i want to use it to display the health of the player
Send a new message
ah just a new
i want to change only sword displayname when player pickup it if the sword equals player name
i tried to use this code:
if (item.getType() == Material.DIAMOND_SWORD && item.getItemMeta().hasDisplayName()) {
if (item.getItemMeta().getDisplayName().contains(event.getPlayer().getName())) {
event.setCancelled(true);
} else {
normal.setDisplayName(ChatAPI.color("&eDiamond Sword"));
}```
the code works but they don't change item name
if the sword don't equals player name it's change it to &eDiamond Sword
More code pls. Do you apply the ItemMeta to the ItemStack again?
else cancel pickup
okay @lost matrix
yes i did
@EventHandler
public void onPick(PlayerPickupItemEvent event) {
ItemStack item = event.getItem().getItemStack();
ItemStack original = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta normal = original.getItemMeta();
original.setItemMeta(normal);
if (item.getType() == Material.DIAMOND_SWORD && item.getItemMeta().hasDisplayName()) {
if (item.getItemMeta().getDisplayName().contains(event.getPlayer().getName())) {
event.setCancelled(true);
} else {
normal.setDisplayName(ChatAPI.color("&eDiamond Sword"));
}
} else {
return;
}
}```
oh
is there something like an .setCollidable(false) in the entitySpawnEvent?
😳
Hello, guys!
I want to modify the BookMeta of a Book and Quill when the player opens it to provide a translated version of a text based on the client's language, but the book UI is first opened and then the Meta modified, no the changes are not noticeable until you reopen the book.
I tried force-closing the book by closing the inventory of the player and then using player.openBook(), but the Material needs to be WRITTEN_BOOK and i need it to be WRITABLE_BOOK.
Any ideas?
Are you spawning the entity?
no naturally
Aight dely that with one tick
i just forget to set ItemMeta thx btw ❤️
Check if it's an instance of LivingEntity and cast
last question is there anyway to update scoreboard with out flicker
Prefix and suffix
Was this a response to me?
try it
yes
That would require the method to be enclosed in a try catch... which is what I am trying to clean up
You want this only for checked exceptions?
or let the jvm handle the exceptions
yes posted an example of the code it runs in try catch
its ok to have many try catch blocks
I know its ok to lol. But thats not the question
still collision..
Im this far right now:
@FunctionalInterface
public interface ThrowingConsumer<T, E extends Exception> {
void accept(T t) throws E;
static <T> Consumer<T> wrapper(final ThrowingConsumer<T, Exception> throwingConsumer) {
return value -> {
try {
throwingConsumer.accept(value);
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
};
}
}
Let me make it a bit more modular...
Wait i should test if this works first...
💀
You might need to disable collision for the player too
It works:
final File targetFile = new File("test");
final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(targetFile);
ThrowingConsumer.<File>wrapper(configuration::save).accept(targetFile);
That alot more code then just try catch though lol.
hm
Its literally just one line
yeah I like that. Just thought there was maybe something like as long as a method name.
@lost matrix i am totally confused with the materials. i can use #getMaterial() but that doesnt return org.bukkit.Material
im confused
I'll try to implement it. Thanks
I know why I wanted a method now.. I need to do multiple methods in the try catch... load/save/create all in 1 try catch which is why I did runnable
You can do all that in a consumer.
@Override
public void onEnable() {
final File targetFile = new File("test");
final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(targetFile);
ThrowingConsumer.<File>wrapper(file -> this.doRandomStuffToFile(configuration, file)).accept(targetFile);
}
private void doRandomStuffToFile(final YamlConfiguration configuration, final File file) throws Exception {
// Do a bunch of stuff in here
}
wew
Thanks. IDK if this is the route I want though.
I'm trying to use this https://github.com/yannicklamprecht/WorldBorderAPI but I cant add the dependency
You need the repository
I have it.
WorldBorderAPI
unless its on maven centeal
case sensitive, are you using jitpack
no
add it as a repository
nvm
it uses this repo
<repositories>
<repository>
<id>eldonexus</id>
<url>https://eldonexus.de/repository/maven-releases/</url>
</repository>
</repositories>
wtf is this
@lost matrix i am totally confused with the materials. i can use #getMaterial() but that doesnt return org.bukkit.Material
help
code?
I do have the correct repository but it doesnt find the dependency
contact the dev
does anyone have any idea how you'd go about hosting your maven artefacts on your own site?
i have a EntityFallingBlock, and i need to get the material out of it
but that returns net.minecraft.world.level.material.Material
and not org.bukkit.Material
stupid actionbar doesnt work
lmao
@quaint mantle
Material.valueOf(net.minecraft.world.level.material.Material#name) should work surely
unless the names are differennt
and since NMS Material and Bukkit Material do the same thing, I'd see no reason as to why they'd be different
but theres no direct way to get the bukkit one from the NMS one since bukkit is built on top of NMS, so NMS has no idea bukkit exists, hence it not being able to give an NMS -> Bukkit method
@regal moat
anything we can help with?
uhh this is my code
public class ActionBar extends BukkitRunnable {
private final Player player;
private final String text;
private int start = 0;
public ActionBar(Player player, String text) {
this.player = player;
this.text = text;
}
@Override
public void run() {
start++;
Utils.sendActionBar(player, text);
}
}
and inside the playerjoin i use new ActionBar(p, sometext).run()
Why are you creating an object for it?
Dont. You need to schedule this instance using the BukkitScheduler
Ah, can I see where you attach ActionBar to the scheduler, and show is the code to Utils#sendActionBar
public static void sendActionBar(Player player, String message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
}```
and the scheduler attachment?
huuh
basically wherever you ran ActionBar bar = new ActionBar() you need to put something like Bukkit.getScheduler().runTaskTimer(plugin, () -> bar.run());
oh
lol...
inside that class?
its one way to do it lmfao
new ActionBar().runTaskTimer(plugin, 1, 1);
No
I still think that a object for this is overkill but it works
so something like this?
public void run() {
Bukkit.getScheduler().runTask(Main.getInstance(), () -> Utils.sendActionBar(player, text));
}
😳
Wtf
do what smile did
essentially
Then get rid of "extends Runnable" please
forgot how the scheduler worked for a sec there
the extends runnable is what allows him to attach it to the scheduler in the way he's doing kt
@tardy delta you good now?
uhh i'm reading
If he does that then he wont be able to schedule it. Extending BukkitRunnable here is correct.
I believe the idea here is to make it go on for a set amount of time
that gives out an error. but Material.valueOf(String.valueOf(fallingBlock.getBlock().getMaterial())) doesnt
Wth
i have no idea
Hmm yeah I can tell
What are you trying to do?
does it work though 👀
Unless the Enum member declarations Match up
By default it should (for toString = Name)
afaik, all enums toString return the name?
Yeah Idk if it’s overridden or something
ToString can be overriden
Name cannot
whats the error when you try to use name?
I thought any derivative of the Enum class by default just returns its garbage value
yeah, but I dont see why it would be, its worth checking though
Lemme see
I'd be able to test it but I'm not at my PC
Hmm alright good to know
Enum#name ALWAYS returns String
i am using intellij
Material#name doesnt return Material
Then fuck IJ - though I think you Just plainly messed up
so what should i do here
Make Sure you call .name
(is NMS Material even an Enum?)
?stash
whats the point in that
Mods
Converting enums into registries is a PITA
sorry, whats a PITA
Especially If you have the kind of insanity that the Bukkit Material Enum has
Pain in the ass
there's no way to look at NMS code without decompiling it is there?
(like no github or stash)
NMS = mojang
Somebody know why a drinkable instant damage potion don't trigger the EntityDamageEvent ?
I. E. All Rights Reserved
strange
The throwable potions trigger the event with the cause "magic" but the drinkable not 😄
Apparently suicide does no damage
what doesn't kill you makes you stronger
Ask the plugin author about that
Как можно у игроков забирать опыт?
hes talking about spigot/bukkit
Why suicide, the potion dont kill you instantly 😄
player.setExp(player.getExp() - сумма чтобы взять)
какие ошибки в консоли?
Может позвоню?
Ты русский?
Ошибка там типо пишет что не может быть больше 1
Это полоска
Но giveExp получается выдавать
А забрать никак
Я использую сайт переводов, возможно, я не смогу
что происходит, когда вы пытаетесь использовать это
секунду
just a second
Hello! I have a problem with my local maven repo, after built BuildTools. That is, when I add as a dependency in IntelliJ(as a library), I can't see its commets. Just like it make library file simply small and has no comment, and some of variable show only var0, var1, var2, etc. It is hard to read and follow the library. How to deal with that?
Here is example:
- original: https://ibb.co/K0YmkcH
did you add javadocs to your pom?
- what I see in IntelliJ: https://ibb.co/DY7ZshB
Yeah
@fading lake
You’re depending on a decompiled jar just like that? Not a maven artifact dependency or anything like that.
dependency: https://ibb.co/ww8CKJC
Yes, so how to do then?
[19:09:42 ERROR]: Could not pass event PlayerInteractEvent to asas v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Paper-1618]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:236) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:486) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1011) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1618]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_291]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_291]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:850) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666) ~[patched_1.12.2.jar:git-Paper-1618]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.IllegalArgumentException: Experience progress must be between 0.0 and 1.0 (-1394.0625)
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer.setExp(CraftPlayer.java:981) ~[patched_1.12.2.jar:git-Paper-1618]
at test.Ender.Two(Ender.java:115) ~[?:?]
at test.Ender.Two(Ender.java:50) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor110.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1618]
... 17 more
1
1
1
Caused by: java.lang.IllegalArgumentException: Experience progress must be between 0.0 and 1.0 (-1394.0625)
@quaint mantle https://pastebin.com/
okay
add xml <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>${project.spigotVersion}</version> <type>javadoc</type> <scope>provided</scope> </dependency>
You probably want to add the respective sources jar to your classpath
Ohh
player.setExp(Math.max(0, player.getExp() - сумма чтобы взять));
You see when compiling, local variable and parameter names are lost
I'm not clearly understand that
just a second
опыт падает ниже 0, это должно исправить
So we need to add a sources jar to the classpath which contains all the classes from the dependency but not compiled to class files (they’re still .java files)
потому что вы берете больше опыта, чем у них
For me, I don't have that javadoc, just jar
no
add it and it will be pulled from the spigot repo
ошибка говорила, что вы пытались установить их опыт на -1394.0625
did you fill in the version?
Filled
Yes, I have level 40
it works fine, you have to have one for the spigot-api and one for the javadocs
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
подожди, ты имеешь в виду уровень или опыт
exp
This is minexml <!--Bukkit/Spigot API --> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>${project.spigotVersion}</version> <scope>provided</scope> </dependency> <!-- Spigot Javadocs --> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>${project.spigotVersion}</version> <type>javadoc</type> <scope>provided</scope> </dependency>
Ohh
sry for late reply I went to sleep cause it was rlly late for me
and yes I do have multiple instances of the class that contain the "PlayerGuilds" hash map
so how do i make it so when i change PlayerGuilds of an instance, the original player guilds also change? also ty for the uuid tip ill change it rn
пытаться player. setTotalExperience(Math.max(0, player.getTotalExperience() - сумма чтобы взять));
please help, i need to replace all '&#(a-fA-F0-9)' with ChatColor.of("#(a-fA-F0-9)")
It still doesn't work for me
What isn't working about it?
Still the same as before
have you manually added some other jars?
What others?
this simply resets the experience scale
It works perfectly if you've not added somethign manually ```java
/**
-
Represents a player, connected or not
*/
public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient {/**
- Gets the "friendly" name to display of this player. This may include
- color.
- <p>
- Note that this name will not be displayed in game, only in chat and
- places defined by plugins.
- @return the friendly name
*/
@NotNull
public String getDisplayName();```
that is what I see for Player
Yeah, for me don't😔
what dependencies do you have in yoru ide?
@fading lake
what is the type of a function function or whatever is used in java for callbacks? specifically o want to send a lambda expression to a function to call when finishing something
how to take experience from players?
Only this
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
</dependencies>
Consumer<T> for defining functionality for later usage.
Callbacks should be done using CompletableFutures or the Future API in general.
что показывает player.getTotalExperience() - сумма чтобы взять
Thats all that is in your pom. You have something else as you showed us a screen of some decompiled jar
Add negative experience
total experience is just for statistical purpose
What do you really mean?
it doesn't work, it lowers the level, but it doesn't show. as a result, the bug is broken and it will no longer be possible to issue a level
I'm using IntelliJ
@lost matrix
do all the dependencies show as fine in Intelij? No red underscores