Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #470 Automatically disable cheat mode if it is not permitted
- Loading branch information
Showing
13 changed files
with
235 additions
and
70 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package mezz.jei.network; | ||
|
||
public enum PacketIdClient implements IPacketId { | ||
INVALID; | ||
CHEAT_PERMISSION; | ||
|
||
public static final PacketIdClient[] VALUES = values(); | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/mezz/jei/network/packets/PacketCheatPermission.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,42 @@ | ||
package mezz.jei.network.packets; | ||
|
||
import java.io.IOException; | ||
|
||
import mezz.jei.config.Config; | ||
import mezz.jei.network.IPacketId; | ||
import mezz.jei.network.PacketIdClient; | ||
import mezz.jei.util.CommandUtil; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.network.PacketBuffer; | ||
import net.minecraft.util.text.TextFormatting; | ||
|
||
public class PacketCheatPermission extends PacketJei { | ||
private final boolean hasPermission; | ||
|
||
public PacketCheatPermission(boolean hasPermission) { | ||
this.hasPermission = hasPermission; | ||
} | ||
|
||
@Override | ||
public IPacketId getPacketId() { | ||
return PacketIdClient.CHEAT_PERMISSION; | ||
} | ||
|
||
@Override | ||
public void writePacketData(PacketBuffer buf) { | ||
buf.writeBoolean(hasPermission); | ||
} | ||
|
||
public static class Handler implements IPacketJeiHandler { | ||
@Override | ||
public void readPacketData(PacketBuffer buf, EntityPlayer player) throws IOException { | ||
boolean hasPermission = buf.readBoolean(); | ||
if (!hasPermission && Config.isCheatItemsEnabled()) { | ||
CommandUtil.writeChatMessage(player, "jei.chat.error.no.cheat.permission.1", TextFormatting.RED); | ||
CommandUtil.writeChatMessage(player, "jei.chat.error.no.cheat.permission.2", TextFormatting.RED); | ||
Config.setCheatItemsEnabled(false); | ||
player.closeScreen(); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.