the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 85 lines 2.2 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.commands.h" 3#include "..\Minecraft.Client\MinecraftServer.h" 4#include "..\Minecraft.Client\ServerLevel.h" 5#include "net.minecraft.network.packet.h" 6#include "TimeCommand.h" 7 8EGameCommand TimeCommand::getId() 9{ 10 return eGameCommand_Time; 11} 12 13int TimeCommand::getPermissionLevel() 14{ 15 return LEVEL_GAMEMASTERS; 16} 17 18void TimeCommand::execute(shared_ptr<CommandSender> source, byteArray commandData) 19{ 20 ByteArrayInputStream bais(commandData); 21 DataInputStream dis(&bais); 22 23 bool night = dis.readBoolean(); 24 25 bais.reset(); 26 27 int amount = 0; 28 if(night) amount = 12500; 29 doSetTime(source, amount); 30 //logAdminAction(source, "commands.time.set", amount); 31 logAdminAction(source, ChatPacket::e_ChatCustom, L"commands.time.set"); 32 33 //if (args.length > 1) { 34 // if (args[0].equals("set")) { 35 // int amount; 36 37 // if (args[1].equals("day")) { 38 // amount = 0; 39 // } else if (args[1].equals("night")) { 40 // amount = 12500; 41 // } else { 42 // amount = convertArgToInt(source, args[1], 0); 43 // } 44 45 // doSetTime(source, amount); 46 // logAdminAction(source, "commands.time.set", amount); 47 // return; 48 // } else if (args[0].equals("add")) { 49 // int amount = convertArgToInt(source, args[1], 0); 50 // doAddTime(source, amount); 51 52 // logAdminAction(source, "commands.time.added", amount); 53 // return; 54 // } 55 //} 56 57 //throw new UsageException("commands.time.usage"); 58} 59 60void TimeCommand::doSetTime(shared_ptr<CommandSender> source, int value) 61{ 62 for (int i = 0; i < MinecraftServer::getInstance()->levels.length; i++) 63 { 64 MinecraftServer::getInstance()->levels[i]->setDayTime(value); 65 } 66} 67 68void TimeCommand::doAddTime(shared_ptr<CommandSender> source, int value) 69{ 70 for (int i = 0; i < MinecraftServer::getInstance()->levels.length; i++) 71 { 72 ServerLevel *level = MinecraftServer::getInstance()->levels[i]; 73 level->setDayTime(level->getDayTime() + value); 74 } 75} 76 77shared_ptr<GameCommandPacket> TimeCommand::preparePacket(bool night) 78{ 79 ByteArrayOutputStream baos; 80 DataOutputStream dos(&baos); 81 82 dos.writeBoolean(night); 83 84 return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Time, baos.toByteArray() )); 85}