Skip to content

Commit ac37711

Browse files
authored
Merge pull request #1 from lumi-git/v1.5.0
v1.5.0
2 parents 1c5bf71 + a42d500 commit ac37711

File tree

7 files changed

+929
-60
lines changed

7 files changed

+929
-60
lines changed

pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@
2121
</repositories>
2222

2323
<dependencies>
24-
2524
<dependency>
2625
<groupId>org.spigotmc</groupId>
2726
<artifactId>spigot-api</artifactId>
2827
<version>1.15-R0.1-SNAPSHOT</version>
2928
<scope>provided</scope>
3029
</dependency>
30+
<dependency>
31+
<groupId>org.bstats</groupId>
32+
<artifactId>bstats-bukkit</artifactId>
33+
<version>3.0.2</version>
34+
<scope>compile</scope>
35+
</dependency>
3136
</dependencies>
3237

3338

@@ -65,6 +70,14 @@
6570
</configuration>
6671
</execution>
6772
</executions>
73+
<configuration>
74+
<relocations>
75+
<relocation>
76+
<pattern>org.bstats</pattern>
77+
<shadedPattern>fr.lumi</shadedPattern>
78+
</relocation>
79+
</relocations>
80+
</configuration>
6881
</plugin>
6982
</plugins>
7083
<resources>

src/main/java/fr/lumi/Commandes/CommandRunnerCommand.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String alia
116116

117117
@Override
118118
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
119+
119120
if (args.length == 0){
120121
sender.sendMessage(plugin.getUt().replacePlaceHoldersForPlayerPlgVar("&7This commands require more arguments! Use /acmdhelp for more information."));
121122
return true;
122123
}
123124

125+
CommandSender player = sender;
126+
124127
if (args.length >= 1) {
125128
if (Objects.equals(args[0], "list")) {
126129

@@ -279,13 +282,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
279282
}
280283

281284

282-
283-
284-
285-
286-
287-
288-
289285
if (Objects.equals(args[0], "delete") && args.length >= 2) {
290286

291287
String id = args[1];
@@ -351,11 +347,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
351347
index++;
352348
}
353349
player.sendMessage(plugin.getUt().replacePlaceHoldersForPlayer(plugin.getLangConfig().getString("onAddingANewCommand"), cmd));
354-
355-
356350
cmd.saveInConfig(plugin.getCommandsConfig(), plugin);//sauvegarde de la commande dans le fichier de commands
357-
358-
359351
cmd.setRunning(cmd.isRunning(), plugin.getCommandsConfig(), plugin);
360352
plugin.getcommandList().add(cmd);
361353

src/main/java/fr/lumi/Commandes/CommandRunnerEditor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
4242

4343
valid = valid && openMenu( (Player) sender);
4444
if(!valid) return false;
45-
player.sendMessage(plugin.getUt().replacePlaceHoldersForPlayerPlgVar("&eMenu Opened"));
46-
4745

4846
valid = valid && SaveMenu();
4947
if(!valid) return false;

src/main/java/fr/lumi/Main.java

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fr.lumi.Commandes.CommandRunnerCommand;
44
import fr.lumi.Commandes.CommandRunnerEditor;
55
import fr.lumi.Commandes.CommandRunnerHelp;
6-
6+
import fr.lumi.Metrics.Metrics;
77
import fr.lumi.Commandes.CommandRunnerReload;
88
import fr.lumi.FileVerifiers.ConfigFileVerification;
99
import fr.lumi.FileVerifiers.LangFileVerification;
@@ -23,14 +23,13 @@ public final class Main extends JavaPlugin {
2323

2424
private String[] Logo ={
2525
"&e&9 &6__ __ &e ",
26-
"&e&9 /\\ &6/ |\\/|| \\&e| &9Auto&6Commands &aVersion &e1.2.1",
26+
"&e&9 /\\ &6/ |\\/|| \\&e| &9Auto&6Commands &aVersion &e1.5.2",
2727
"&e&9/--\\&6\\__| ||__/&e| &8running on bukkit - paper",
2828
""};
2929

30-
31-
32-
3330
FileConfiguration config = getConfig();
31+
32+
// TODO: implement condition system
3433
ConditionVerifier amcdVerifier = new ConditionVerifier(this);
3534
dailyCommandExecuter executer;
3635
CommandEditor acmdGUIEditor;
@@ -71,34 +70,16 @@ public FileConfiguration getLangConfig() {
7170
return Langconfig;
7271
}
7372

74-
public FileConfiguration getLangConfigWithoutreload() {
75-
return Langconfig;
76-
}
77-
7873

7974
public File getLangFile() {
8075
Langfile= new File(getDataFolder(),"lang.yml");
8176
return Langfile;
8277
}
8378

84-
public boolean saveLangFilewithLoad() {
85-
try {
86-
getLangConfig().save(getLangFile());
87-
} catch (IOException ignored){
88-
return false;
89-
}
90-
return true;
91-
}
92-
93-
9479

95-
public boolean saveLangFile() {
96-
try {
97-
getLangConfigWithoutreload().save(getLangFile());
98-
} catch (IOException ignored){
99-
return false;
100-
}
101-
return true;
80+
public void addBstatsMetrics(){
81+
int pluginId = 21737;
82+
Metrics metrics = new Metrics(this, pluginId);
10283
}
10384

10485

@@ -139,6 +120,10 @@ public void init(){
139120

140121
@Override
141122
public void onEnable() {
123+
124+
// add bstat metrics
125+
addBstatsMetrics();
126+
142127
long start = System.currentTimeMillis();
143128
init();
144129

@@ -147,14 +132,10 @@ public void onEnable() {
147132

148133
saveDefaultConfig();
149134
getRessourceFile(getLangFile(),"lang.yml",this);
150-
//saveLangFile();
151135
boolean verified = Load();
152136

153137
long exeTime = System.currentTimeMillis() - start;
154138
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',config.getString("ConsolePrefix")+" &aOn (took "+exeTime+" ms)"));
155-
156-
157-
158139
}
159140

160141
public boolean verifyFiles(){
@@ -164,30 +145,26 @@ public boolean verifyFiles(){
164145
return verified;
165146
}
166147

167-
168-
169148
@Override
170149
public void onDisable() {
171150
Unload();
172-
173151
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',config.getString("ConsolePrefix")+" &cOff"));
174152
}
175153

176154
public boolean Load() {
177155
boolean verified = false;
156+
178157
verified = verifyFiles();
158+
if (!verified) {
159+
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',config.getString("ConsolePrefix")+"&4Ignore these errors if this is the first time you are running the plugin."));
160+
}
161+
179162
reloadConfig();
180163
config = getConfig();
181-
182-
183-
184-
185-
186164
Objects.requireNonNull(this.getCommand("acmdhelp")).setExecutor(new CommandRunnerHelp(this));
187165
Objects.requireNonNull(this.getCommand("acmd")).setExecutor(new CommandRunnerCommand(this));
188166
Objects.requireNonNull(this.getCommand("acmdreload")).setExecutor(new CommandRunnerReload(this));
189167

190-
191168
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',config.getString("ConsolePrefix")+ "&e-Loading "+getCommandsConfig().getKeys(false).size()+" AutoComands-"));
192169

193170
//loading the commands in the plugin
@@ -277,8 +254,6 @@ public int getRunningCommand(){
277254
return count;
278255
}
279256

280-
281-
282257
public long convertToTick(long seconds){
283258
return (long) seconds*20;
284259
}
@@ -290,7 +265,6 @@ public static void getRessourceFile(File file, String resource, Main plugin) {
290265
file.createNewFile();
291266
InputStream inputStream = plugin.getResource(resource);
292267
OutputStream outputStream = new FileOutputStream(file);
293-
294268
byte[] buffer = new byte[1024];
295269
int bytesRead;
296270
while ((bytesRead = inputStream.read(buffer)) != -1) {
@@ -303,9 +277,6 @@ public static void getRessourceFile(File file, String resource, Main plugin) {
303277
} catch (IOException e) {
304278
e.printStackTrace();
305279
}
306-
307280
YamlConfiguration.loadConfiguration(file);
308281
}
309-
310-
311282
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package fr.lumi.Metrics;
2+
3+
import java.util.function.BiConsumer;
4+
5+
public abstract class CustomChart {
6+
7+
private final String chartId;
8+
9+
protected CustomChart(String chartId) {
10+
if (chartId == null) {
11+
throw new IllegalArgumentException("chartId must not be null");
12+
}
13+
this.chartId = chartId;
14+
}
15+
16+
public Metrics.JsonObjectBuilder.JsonObject getRequestJsonObject(
17+
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
18+
Metrics.JsonObjectBuilder builder = new Metrics.JsonObjectBuilder();
19+
builder.appendField("chartId", chartId);
20+
try {
21+
Metrics.JsonObjectBuilder.JsonObject data = getChartData();
22+
if (data == null) {
23+
// If the data is null we don't send the chart.
24+
return null;
25+
}
26+
builder.appendField("data", data);
27+
} catch (Throwable t) {
28+
if (logErrors) {
29+
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
30+
}
31+
return null;
32+
}
33+
return builder.build();
34+
}
35+
36+
protected abstract Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception;
37+
}

0 commit comments

Comments
 (0)