Skip to content

Commit

Permalink
Merge pull request #14 from preprocessor/main
Browse files Browse the repository at this point in the history
Fixed the welcome message
  • Loading branch information
Beta-51 authored Apr 14, 2024
2 parents 3ace5aa + a060041 commit 552e14a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
12 changes: 10 additions & 2 deletions src/main/java/lusiiplugin/mixin/EntityPlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

@Mixin(value = EntityPlayer.class, remap = false)
public class EntityPlayerMixin extends EntityLiving {

@Shadow
protected boolean isDwarf;

public EntityPlayerMixin(World world) {
super(world);
}
Expand All @@ -21,7 +25,11 @@ protected void init() {

@Overwrite
public double getRidingHeight() {
return this.heightOffset + 0.42;
}
double rideOffset = 0.5;

if (this.vehicle instanceof EntityPlayer) {
rideOffset = -0.12;
}
return this.isDwarf ? this.heightOffset + (rideOffset / 10.0) : (this.heightOffset - rideOffset);
}
}
27 changes: 27 additions & 0 deletions src/main/java/lusiiplugin/mixin/NetLoginHandlerMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lusiiplugin.mixin;

import net.minecraft.core.net.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.net.handler.NetLoginHandler;
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 = NetLoginHandler.class, remap = false)
public abstract class NetLoginHandlerMixin {
@Shadow
private MinecraftServer mcServer;

@Inject(method = "doLogin", at = @At("TAIL"))
private void welcomeMessage(Packet1Login packet1login, CallbackInfo ci) {
File playerData = new File("world/players/" + packet1login.username + ".dat");

if (!playerData.exists()) {
this.mcServer.serverCommandHandler.sendMessageToAllPlayers("§4Welcome §3" + packet1login.username + "§4 to the server!" );
}
}
}
30 changes: 0 additions & 30 deletions src/main/java/lusiiplugin/mixin/PlayerManagerMixin.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/lusiiplugin.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"HelpCommandMixin",
"NetServerHandlerMixin",
"NicknameCommandMixin",
"PlayerManagerMixin",
"NetLoginHandlerMixin",
"SpawnCommandMixin",
"TreecapitatorMixin"
],
Expand Down

0 comments on commit 552e14a

Please sign in to comment.