Skip to content

Commit 802f50d

Browse files
committed
added new config option and check for server crashes. Fixes issue #24
1 parent 4cdee8f commit 802f50d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/main/java/pw/hwk/tutorial/TutorialConfigs.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ public class TutorialConfigs {
1616
private int perTutorialExp;
1717
private int perViewExp;
1818
private double perViewMoney;
19+
private boolean checkGameMode;
1920

2021

2122
public TutorialConfigs(boolean autoUpdate, String signSetting, boolean firstJoin, String firstJoinTutorial,
2223
boolean rewards, boolean expCountdown, boolean viewMoney, boolean viewExp, boolean
2324
tutorialMoney, boolean tutorialExp, double perTutorialMoney, int perTutorialExp,
24-
int perViewExp, double perViewMoney) {
25+
int perViewExp, double perViewMoney, boolean checkGameMode) {
2526

2627
this.autoUpdate = autoUpdate;
2728
this.signSetting = signSetting;
@@ -37,6 +38,7 @@ public TutorialConfigs(boolean autoUpdate, String signSetting, boolean firstJoin
3738
this.perTutorialExp = perTutorialExp;
3839
this.perViewExp = perViewExp;
3940
this.perViewMoney = perViewMoney;
41+
this.checkGameMode = checkGameMode;
4042
}
4143

4244
public boolean getUpdate() {
@@ -94,4 +96,8 @@ public int getPerTutorialExp() {
9496
public int getPerViewExp() {
9597
return this.perViewExp;
9698
}
99+
100+
public boolean getCheckGameMode() {
101+
return this.checkGameMode;
102+
}
97103
}

src/main/java/pw/hwk/tutorial/TutorialListener.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Set;
3030
import java.util.UUID;
3131
import java.util.logging.Level;
32+
import org.bukkit.GameMode;
3233

3334
public class TutorialListener implements Listener {
3435

@@ -172,6 +173,9 @@ public void onWhee(EntityDamageEvent event) {
172173
public void onJoin(PlayerJoinEvent event) {
173174
final Player player = event.getPlayer();
174175
final String playerName = player.getName();
176+
if (TutorialManager.getManager().getConfigs().getCheckGameMode()) {
177+
event.getPlayer().setGameMode(GameMode.SURVIVAL);
178+
}
175179
if (!plugin.getServer().getOnlineMode()) {
176180
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
177181
@Override

src/main/java/pw/hwk/tutorial/data/Caching.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void cacheConfigs() {
153153
.getBoolean("view_exp"), plugin.getConfig().getBoolean("tutorial_money"), plugin.getConfig()
154154
.getBoolean("tutorial_exp"), Double.valueOf(plugin.getConfig().getString("per_tutorial_money")),
155155
Integer.valueOf(plugin.getConfig().getString("per_tutorial_exp")), Integer.valueOf(plugin.getConfig()
156-
.getString("per_view_exp")), Double.valueOf(plugin.getConfig().getString("per_view_money")));
156+
.getString("per_view_exp")), Double.valueOf(plugin.getConfig().getString("per_view_money")), plugin.getConfig().getBoolean("check_gamemode"));
157157
this.addConfig(configOptions);
158158
}
159159

0 commit comments

Comments
 (0)