Skip to content

Commit f600ff3

Browse files
committed
Fix small join/leave bug
1 parent d9d1982 commit f600ff3

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/main/java/net/cybercake/fallback/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void reload() {
3434
this.spawn = new Location(Main.getPlugin().getServer().getWorlds().get(0), 0.0, 100.0, 0.0, 0, 0);
3535
}
3636

37-
this.joinLeaveEvents = config.getBoolean("disable.joinLeaveEvents");
37+
this.joinLeaveEvents = config.getBoolean("disable.joinLeaveMessages");
3838
this.chat = config.getBoolean("disable.chat");
3939
this.movement = config.getBoolean("disable.movement");
4040
}

src/main/java/net/cybercake/fallback/commands/FallbackReload.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
2222
try {
2323
long mss = System.currentTimeMillis();
2424

25-
Main.getPlugin().saveDefaultConfig();
26-
Main.getPlugin().reloadConfig();
25+
Main.getInstance().getConfiguration().reload();
2726

2827
sender.sendMessage(UChat.component("&6Successfully reloaded the fallback configuration in &a" + (System.currentTimeMillis()-mss) + "&ams&6!"));
2928
Spigot.playSound(sender, Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);

src/main/java/net/cybercake/fallback/listeners/JoinLeaveEvent.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import net.cybercake.fallback.Configuration;
44
import net.cybercake.fallback.Main;
5-
import net.kyori.adventure.text.Component;
5+
import org.bukkit.GameMode;
6+
import org.bukkit.entity.Player;
67
import org.bukkit.event.EventHandler;
78
import org.bukkit.event.Listener;
89
import org.bukkit.event.player.PlayerJoinEvent;
@@ -15,15 +16,20 @@ public void onJoin(PlayerJoinEvent event) {
1516
Configuration configuration = Main.getInstance().getConfiguration();
1617
if(!configuration.disableJoinLeaveEvents()) return;
1718

18-
event.joinMessage(Component.empty());
19-
event.getPlayer().teleport(configuration.getSpawn());
19+
event.joinMessage(null);
20+
21+
Player player = event.getPlayer();
22+
player.setGameMode(GameMode.SPECTATOR);
23+
player.teleport(configuration.getSpawn());
24+
25+
Main.getInstance().send(player, configuration.getConnectTo());
2026
}
2127

2228
@EventHandler
2329
public void onQuit(PlayerQuitEvent event) {
2430
if(!Main.getInstance().getConfiguration().disableJoinLeaveEvents()) return;
2531

26-
event.quitMessage(Component.empty());
32+
event.quitMessage(null);
2733
}
2834

2935
}

0 commit comments

Comments
 (0)