[Megameknet-cvs] MegaMekNET/src/server/campaign/commands AdminSetFactoryCommand.java,NONE,1.1
Status: Inactive
Brought to you by:
mcwizard
From: Helge R. <mcw...@us...> - 2005-02-22 20:46:39
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14728/src/server/campaign/commands Added Files: AdminSetFactoryCommand.java Log Message: -> S Fixed Hangar Bugs -> S Added AdminSetFactory Command --- NEW FILE: AdminSetFactoryCommand.java --- /** * MegaMekNET * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ package server.campaign.commands; import java.util.*; import server.campaign.SUnitFactory; import server.campaign.SPlanet; import server.campaign.CampaignMain; public class AdminSetFactoryCommand extends Command { public void process(StringTokenizer command,String userName) { if (CampaignMain.cm.getServer().isAdmin(userName)) { try{ SPlanet p = CampaignMain.cm.getPlanetFromPartialString(command.nextToken(),userName); String factoryname = command.nextToken(); int newType = Integer.parseInt(command.nextToken()); if ( p == null ) { CampaignMain.cm.toUser("Planet not found:",userName,true); return; } SUnitFactory UF = null; Iterator it = p.getUnitFactories().iterator(); if ( !it.hasNext() ) { CampaignMain.cm.toUser("This planet does not have any factories!",userName,true); return; } int count = 0; while (it.hasNext()){ UF = (SUnitFactory)it.next(); if ( UF.getName().equalsIgnoreCase(factoryname) ) { UF.setType(newType) break; } count++; } if ( UF == null ){ CampaignMain.cm.toUser("Factory " + factoryname + " not found",userName,true); return; } server.MMServ.mmlog.modLog("Factory " + factoryname + " has been set to mode: " + newType); CampaignMain.cm.toUser("Factory " + factoryname + " has been set to mode: " + newType,userName,true); } catch (Exception ex){ ex.printStackTrace(); } } } } |