-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerList.java
More file actions
57 lines (34 loc) · 1.34 KB
/
PlayerList.java
File metadata and controls
57 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package de.luke.naruto;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerList implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendMessage("§aWilkommen");
String playerName = player.getName();
File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase");
File f = new File(userdata, File.separator + playerName + ".yml");
FileConfiguration playerData = YamlConfiguration.loadConfiguration(f);
int x = playerData.getInt("stats.totalLogins") + 1;
playerData.set("stats.totalLogins", x);
if (playerData.getInt("xplevel.balance") < 100) {
playerData.set("xplevel.balance", 100);
}
if (playerData.getInt("force") < 1) {
playerData.set("force", 1);
}
try {
playerData.save(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}