<commit_before>package com.skcraft.plume.module;

import com.sk89q.intake.Command;
import com.sk89q.intake.Require;
import com.skcraft.plume.command.Sender;
import com.skcraft.plume.common.util.SharedLocale;
import com.skcraft.plume.common.util.module.Module;
import com.skcraft.plume.util.PlayerData;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import lombok.extern.java.Log;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.common.DimensionManager;

import java.io.IOException;

@Module(name = "mod-mode")
@Log
public class ModMode {

    @Command(aliases = "mod", desc = "Enable moderator mode")
    @Require("plume.moderator.mod")
    public void enableModMode(@Sender ICommandSender sender) {
        if(sender instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) sender;
            PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + player.getGameProfile().getId().toString() + ".dat");
            PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + player.getGameProfile().getId().toString() + ".dat");
            if(!backupData.getFile().exists()) {
                try {
                    backupData.load(player);
                    backupData.save();
                    modInv.load();
                    modInv.putInventory(player);
                    MinecraftServer.getServer().getConfigurationManager().func_152605_a(player.getGameProfile());
                    player.setGameType(WorldSettings.GameType.CREATIVE);
                    player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.enter")));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.alreadyEnabled")));
            }
        }
    }

    @Command(aliases = "done", desc = "Disable moderator mode")
    @Require("plume.moderator.done")
    public void disableModMode(@Sender ICommandSender sender) {
        if(sender instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) sender;
            PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + player.getGameProfile().getId().toString() + ".dat");
            PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + player.getGameProfile().getId().toString() + ".dat");
            if(backupData.getFile().exists()) {
                try {
                    modInv.load(player);
                    modInv.save();
                    backupData.load();
                    backupData.putAll(player);
                    backupData.getFile().delete();
                    MinecraftServer.getServer().getConfigurationManager().func_152610_b(player.getGameProfile());
                    player.setGameType(WorldSettings.GameType.SURVIVAL);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.alreadyDisabled")));
            }
        }
    }

    @SubscribeEvent
    public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
        PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + event.player.getGameProfile().getId().toString() + ".dat");
        if(backupData.getFile().exists() && event.player instanceof EntityPlayerMP) {
            try {
                PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + event.player.getGameProfile().getId().toString() + ".dat");
                modInv.load((EntityPlayerMP) event.player);
                modInv.save();
                backupData.load();
                backupData.putAll((EntityPlayerMP) event.player);
                backupData.getFile().delete();
                MinecraftServer.getServer().getConfigurationManager().func_152610_b(event.player.getGameProfile());
                event.player.setGameType(WorldSettings.GameType.SURVIVAL);
            } catch(IOException e) {<commit_msg>Set fall distance to 0 when leaving mod mode.<commit_after>package com.skcraft.plume.module;

import com.sk89q.intake.Command;
import com.sk89q.intake.Require;
import com.skcraft.plume.command.Sender;
import com.skcraft.plume.common.util.SharedLocale;
import com.skcraft.plume.common.util.module.Module;
import com.skcraft.plume.util.PlayerData;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import lombok.extern.java.Log;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.common.DimensionManager;

import java.io.IOException;

@Module(name = "mod-mode")
@Log
public class ModMode {

    @Command(aliases = "mod", desc = "Enable moderator mode")
    @Require("plume.moderator.mod")
    public void enableModMode(@Sender ICommandSender sender) {
        if(sender instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) sender;
            PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + player.getGameProfile().getId().toString() + ".dat");
            PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + player.getGameProfile().getId().toString() + ".dat");
            if(!backupData.getFile().exists()) {
                try {
                    backupData.load(player);
                    backupData.save();
                    modInv.load();
                    modInv.putInventory(player);
                    MinecraftServer.getServer().getConfigurationManager().func_152605_a(player.getGameProfile());
                    player.setGameType(WorldSettings.GameType.CREATIVE);
                    player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.enter")));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.alreadyEnabled")));
            }
        }
    }

    @Command(aliases = "done", desc = "Disable moderator mode")
    @Require("plume.moderator.done")
    public void disableModMode(@Sender ICommandSender sender) {
        if(sender instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) sender;
            PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + player.getGameProfile().getId().toString() + ".dat");
            PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + player.getGameProfile().getId().toString() + ".dat");
            if(backupData.getFile().exists()) {
                try {
                    modInv.load(player);
                    modInv.save();
                    backupData.load();
                    backupData.putAll(player);
                    backupData.getFile().delete();
                    MinecraftServer.getServer().getConfigurationManager().func_152610_b(player.getGameProfile());
                    player.fallDistance = 0;
                    player.setGameType(WorldSettings.GameType.SURVIVAL);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                player.addChatMessage(new ChatComponentText(SharedLocale.tr("modmode.alreadyDisabled")));
            }
        }
    }

    @SubscribeEvent
    public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
        PlayerData backupData = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/temp/" + event.player.getGameProfile().getId().toString() + ".dat");
        if(backupData.getFile().exists() && event.player instanceof EntityPlayerMP) {
            try {
                PlayerData modInv = new PlayerData(DimensionManager.getCurrentSaveRootDirectory().getPath() + "/plume/modinv/" + event.player.getGameProfile().getId().toString() + ".dat");
                modInv.load((EntityPlayerMP) event.player);
                modInv.save();
                backupData.load();
                backupData.putAll((EntityPlayerMP) event.player);
                backupData.getFile().delete();
                MinecraftServer.getServer().getConfigurationManager().func_152610_b(event.player.getGameProfile());
                event.player.setGameType(WorldSettings.GameType.SURVIVAL);
            } catch(IOException e) {
{'fraction_non_alphanumeric': 0.12117962466487936, 'fraction_numerical': 0.004932975871313673, 'mean_word_length': 2.6630007855459543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445728', 'n_tokens_mistral': 2489, 'n_tokens_neox': 2443, 'n_words': 358}