-
-
Save wesserboy/d24fd087d4c34dd68f90 to your computer and use it in GitHub Desktop.
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
package chunkedPVP.commands; | |
import chunkedPVP.worldData.ChunkedPVPWorldData; | |
import net.minecraft.command.CommandBase; | |
import net.minecraft.command.ICommandSender; | |
import net.minecraft.util.ChatComponentTranslation; | |
import net.minecraft.util.ChunkCoordinates; | |
import net.minecraft.world.World; | |
import net.minecraft.world.chunk.Chunk; | |
public class PVPToggleCommand extends CommandBase{ | |
@Override | |
public String getCommandName() { | |
return "togglePVP"; | |
} | |
@Override | |
public String getCommandUsage(ICommandSender var1) { | |
return "Toggles the pvp setting for the chunk the player is currently located in."; | |
} | |
@Override | |
public void processCommand(ICommandSender sender, String[] var2) { | |
ChunkedPVPWorldData data = ChunkedPVPWorldData.forWorld(sender.getEntityWorld()); | |
ChunkCoordinates coords = sender.getPlayerCoordinates(); | |
Chunk chunk = sender.getEntityWorld().getChunkFromBlockCoords(coords.posX, coords.posZ); | |
boolean status; | |
if(data.hasChunk(chunk)){ | |
data.removeChunk(chunk); | |
status = false; | |
}else{ | |
data.addChunk(chunk); | |
status = true; | |
} | |
if(!(data.compound == null)){ | |
data.writeToNBT(data.compound); | |
} | |
data.markDirty(); | |
sender.addChatMessage(new ChatComponentTranslation("PVP Toggled!")); | |
sender.addChatMessage(new ChatComponentTranslation("PVP is now " + status)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment