Skip to content

Commit c412bf9

Browse files
committed
Update examples to reflect the current best practices
1 parent fddb279 commit c412bf9

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

bungeecord/example-plugin/src/main/java/com/example/ExamplePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ExamplePlugin extends Plugin {
2424
// This is useful for cleaning up cached data
2525
.onFlush(() -> gameCount.set(0)) // reset game count on flush
2626

27-
.create(this);
27+
.create();
2828

2929
@Override
3030
public void onDisable() {

core/example/src/main/java/dev/faststats/example/FeatureFlagExample.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package dev.faststats.example;
22

33
import dev.faststats.Attributes;
4+
import dev.faststats.FastStatsContext;
45
import dev.faststats.FeatureFlag;
56
import dev.faststats.FeatureFlagService;
67

78
import java.time.Duration;
89
import java.time.Instant;
910

1011
public final class FeatureFlagExample {
11-
public static final FeatureFlagService SERVICE = FeatureFlagService.create(
12-
"YOUR_TOKEN_HERE", // token can be found in the settings of your project
12+
public static final FeatureFlagService SERVICE = getContext().featureFlags(
1313
Attributes.create() // Define global attributes
1414
.put("version", "1.2.3")
1515
.put("java_version", System.getProperty("java.version"))
@@ -60,4 +60,8 @@ public static void usage() {
6060
}
6161
});
6262
}
63+
64+
private static FastStatsContext getContext() {
65+
return null;
66+
}
6367
}

fabric/example-mod/src/main/java/com/example/ExampleMod.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
import net.fabricmc.api.ModInitializer;
88

99
public class ExampleMod implements ModInitializer {
10-
private final FabricContext context = new FabricContext("YOUR_TOKEN_HERE");
10+
private final FabricContext context = new FabricContext(
11+
"example-mod", // your mod id as defined in fabric.mod.json
12+
"YOUR_TOKEN_HERE"
13+
);
1114
private final Metrics metrics = context.metrics()
1215
// Custom metrics require a corresponding data source in your project settings
1316
.addMetric(Metric.number("example_metric", () -> 42))
1417

1518
// Error tracking must be enabled in the project settings
1619
.errorTracker(ErrorTracker.contextAware())
1720

18-
.create("example-mod"); // your mod id as defined in fabric.mod.json
21+
.create();
1922

2023
@Override
2124
public void onInitialize() {

hytale/example-plugin/src/main/java/com/example/ExamplePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ExamplePlugin extends JavaPlugin {
1616
// Error tracking must be enabled in the project settings
1717
.errorTracker(ErrorTracker.contextAware())
1818

19-
.create(this);
19+
.create();
2020

2121
public ExamplePlugin(final JavaPluginInit init) {
2222
super(init);

0 commit comments

Comments
 (0)