forked from Beta-51/BetterthanVanilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added welcome message for new players
- Loading branch information
1 parent
5c7d394
commit 6c19cc3
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lusiiplugin.mixin; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.entity.player.EntityPlayerMP; | ||
import net.minecraft.server.player.PlayerManager; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.io.File; | ||
|
||
@Mixin(value = PlayerManager.class, remap = false) | ||
public abstract class PlayerManagerMixin { | ||
|
||
@Shadow | ||
@Final | ||
private MinecraftServer server; | ||
|
||
@Inject(method = "addPlayer", at = @At("HEAD")) | ||
private void welcomeMessage(EntityPlayerMP player, CallbackInfo ci) { | ||
File playerData = new File("world/players/" + player.username + ".dat"); | ||
|
||
if (!playerData.exists()) { | ||
server.serverCommandHandler.sendMessageToAllPlayers("§4Welcome §3" + player.username + "§4 to the server!" ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters