This tutorial is set by the author's setting without permission.
You may be an integrated package author, but you don't want your players to cheat in your integrated package, you can use CRT to control it.
Implementation effect:
If the player who logs in itself is the creative mode, you can use any instructions (using GameStage to identify);
If the player name of the login is the author name of the integrated package (or the player you want to specify), then you can use any instructions;
If the player logged in is the survival mode, no instructions are not available (even if the cheating authority is opened).
Before reading this tutorial, I define that readers have basic ZS language use functions. If you do n’t know much, you can try to read other tutorials here.
When writing code, I strongly recommend the Zen Utils module of the Youyihj.
For event applications, you can also view my tutorial.
Step 1: Guide package
Import Crafttweaker.events.ieventmanager;import crafttweaker.event.commandevent;
Import Crafttweaker.event.playerLoggedinevent;
Import crafttweaker.event.playerLogGEDEvent;
import crafttweaker.player.iplayer;
Import crafttweaker.command.icommand;
Step 2: Determine whether the player is the creative mode when logging in
Events.onPlayerLoggedin (function (event as playerLoggedinevent) {// player login eventVar Player as iPlayer = EVENT.Player; // Create an iPlayer object, use variable player to store
If (player.creative) {// Whether the player is the creative mode
Server.ComandManager.executecommand (server, "/GameStage Add"+Player.name+"Creative"); // Give the player game stage stage
}
});
Step 3: Players can use the instruction permissions and disable the player instruction
Events.OnCommand (Function (event as commandevent) {// event with instruction eventsIf (event.commandSender Instanceof iPlayer) {// Otherwise [Note 1]
Var Player as iPlayer = Event.commandSender; // Create an iPlayer object
If (Player.hasgamestage ("Creative") || Player.name == "BigGest_xuan") {// Decision whether the player has the game stage or integrate the author Return;
}
If (! Event.commandSender.World.remote) {// If the instruction is not issued by the server
Event.cancel (); // Cancel the event
Player.SendrichtextMessage (format.red ("Please don't use"+event.command.name+"command"); // Give the player prompt
}}
});
Note 1:
If you do not use Instanceof to determine whether it is the corresponding instance type, it will be reported
java.lang.IncomPatibleClassChangeerror: Class Crafttweaker.mc1120.Command.mCommandSender does Not Implement
The requested interface crafttweaker.api.player.iplayer
So be sure to add the corresponding judgment!