Skip to content

Commit

Permalink
fix: add default config.yml
Browse files Browse the repository at this point in the history
fix #128
  • Loading branch information
Silthus committed Oct 17, 2021
1 parent b9a4e7b commit bf36d49
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
37 changes: 24 additions & 13 deletions src/main/java/net/silthus/template/TemplatePlugin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.silthus.template;

import kr.entree.spigradle.annotations.PluginMain;
import lombok.Getter;
import lombok.experimental.Accessors;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
Expand All @@ -13,21 +15,30 @@
@PluginMain
public class TemplatePlugin extends JavaPlugin implements Listener {

public TemplatePlugin() {}
@Getter
@Accessors(fluent = true)
private static TemplatePlugin instance;

public TemplatePlugin(
JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
}
public TemplatePlugin() {
instance = this;
}

@Override
public void onEnable() {
public TemplatePlugin(
JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
instance = this;
}

getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onEnable() {

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
getLogger().info("Player joined.");
}
saveDefaultConfig();

getServer().getPluginManager().registerEvents(this, this);
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
getLogger().info("Player joined.");
}
}
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# add your default configuration properties here
30 changes: 15 additions & 15 deletions src/test/java/net/silthus/template/TemplatePluginTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@

public class TemplatePluginTests {

private ServerMock server;
private ServerMock server;

@BeforeEach
public void setUp() {
server = MockBukkit.mock();
MockBukkit.load(TemplatePlugin.class);
}
@BeforeEach
public void setUp() {
server = MockBukkit.mock();
MockBukkit.load(TemplatePlugin.class);
}

@Test
public void shouldFirePlayerJoinEvent() {
@Test
public void shouldFirePlayerJoinEvent() {

server.addPlayer();
server.addPlayer();

server.getPluginManager().assertEventFired(PlayerJoinEvent.class);
}
server.getPluginManager().assertEventFired(PlayerJoinEvent.class);
}

@AfterEach
public void tearDown() {
MockBukkit.unmock();
}
@AfterEach
public void tearDown() {
MockBukkit.unmock();
}
}

0 comments on commit bf36d49

Please sign in to comment.