-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make /pronounsset OP-only, /spawnset also sets player respawn, strict…
…er /nick verification
- Loading branch information
Showing
13 changed files
with
162 additions
and
14 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
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
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
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
34 changes: 34 additions & 0 deletions
34
src/server/java/com/kiva/kivaserverutils/NicknameAllowed.java
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,34 @@ | ||
package com.kiva.kivaserverutils; | ||
|
||
import com.fox2code.foxloader.loader.ServerMod; | ||
import net.minecraft.src.game.entity.player.EntityPlayerMP; | ||
|
||
import java.util.Map; | ||
|
||
public class NicknameAllowed { | ||
public static boolean nicknameIsAllowed(final String nickname){ | ||
for (Map.Entry<String, String> playerNick : KivaServerUtils.playerNicknames.entrySet()){ | ||
// Check if someone already has the nickname | ||
if (playerNick.getValue().equalsIgnoreCase(nickname)) | ||
return false; | ||
|
||
// Check if nickname matches a username in playerNicknames | ||
// Not perfect, we'd have to store a null value for players with no nicknames to | ||
// keep a username history, though this could better be achieved by parsing server.log | ||
// but that's pretty hacky and would only fix this small issue where | ||
// someone could set their nickname to a players username if that player | ||
// 1. Doesn't have a nickname | ||
// 2. Isn't currently on the server | ||
if (playerNick.getKey().equalsIgnoreCase(nickname)) | ||
return false; | ||
} | ||
|
||
// Check if nickname matches any username of currently online players | ||
for (EntityPlayerMP p : ServerMod.getOnlinePlayers()){ | ||
if (p.username.equalsIgnoreCase(nickname)) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
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
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
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
19 changes: 19 additions & 0 deletions
19
src/server/java/com/kiva/server/mixins/MixinNetLoginHandler.java
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,19 @@ | ||
package com.kiva.server.mixins; | ||
|
||
import net.minecraft.src.game.entity.player.EntityPlayerMP; | ||
import net.minecraft.src.server.packets.NetLoginHandler; | ||
import net.minecraft.src.server.packets.Packet1Login; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(NetLoginHandler.class) | ||
public class MixinNetLoginHandler { | ||
// Scrapped spawn location dimension code | ||
/*@Inject(method = "doLogin", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT) | ||
public void debugMoment(Packet1Login packet1Login, CallbackInfo ci, EntityPlayerMP entityPlayerMP){ | ||
System.out.println("Dimension in doLogin in the end: " + entityPlayerMP.dimension); | ||
}*/ | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/server/java/com/kiva/server/mixins/MixinServerConfigurationManager.java
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,34 @@ | ||
package com.kiva.server.mixins; | ||
|
||
import com.kiva.kivaserverutils.KivaServerUtils; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.src.game.entity.player.EntityPlayerMP; | ||
import net.minecraft.src.server.ServerConfigurationManager; | ||
import net.minecraft.src.server.packets.NetLoginHandler; | ||
import net.minecraft.src.server.player.PlayerController; | ||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(ServerConfigurationManager.class) | ||
public class MixinServerConfigurationManager { | ||
// Scrapped spawn location dimension code | ||
/*@Shadow private MinecraftServer mcServer; | ||
// If this is the player's first time joining, spawn in the dimension specified with /spawnset | ||
@Inject(method = "login", at = @At("TAIL"), cancellable = true) | ||
public void handlePlayerFirstJoined(NetLoginHandler netLoginHandler, String arg2, CallbackInfoReturnable<EntityPlayerMP> cir){ | ||
if (KivaServerUtils.spawnCommandLocation == null) | ||
return; | ||
cir.setReturnValue(new EntityPlayerMP( | ||
this.mcServer, | ||
this.mcServer.getWorldManager(KivaServerUtils.spawnCommandLocation.dimension), | ||
arg2, | ||
new PlayerController(this.mcServer.getWorldManager(KivaServerUtils.spawnCommandLocation.dimension)) | ||
)); | ||
cir.cancel(); | ||
}*/ | ||
} |
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,25 @@ | ||
package com.kiva.server.mixins; | ||
|
||
import com.kiva.kivaserverutils.KivaServerUtils; | ||
import net.minecraft.src.game.level.World; | ||
import net.minecraft.src.game.level.chunk.ChunkCoordinates; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(World.class) | ||
public class MixinWorld { | ||
@Inject(method = "getSpawnPoint", at = @At("HEAD"), cancellable = true) | ||
public void overRideTheSpawnPoint(CallbackInfoReturnable<ChunkCoordinates> cir){ | ||
if (KivaServerUtils.spawnCommandLocation == null) | ||
return; | ||
|
||
// Don't override the spawn location if spawn was set in the nether | ||
if (KivaServerUtils.spawnCommandLocation.dimension != 0) | ||
return; | ||
|
||
cir.setReturnValue(new ChunkCoordinates((int) KivaServerUtils.spawnCommandLocation.x, (int) KivaServerUtils.spawnCommandLocation.y, (int) KivaServerUtils.spawnCommandLocation.z)); | ||
cir.cancel(); | ||
} | ||
} |
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