Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions MekWarsClient/src/mekwars/admin/AdminMapPopupMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,23 @@ public void actionPerformed(ActionEvent ex) {

public void actionPerformed(ActionEvent ex) {
String planetName = JOptionPane.showInputDialog(mwclient.getGUIClient().getMainFrame(),"Planet Name?");
if ( planetName == null || planetName.length() == 0 )
return;
if (planetName != null && planetName.length() != 0) {
if (CampaignData.cd.getPlanetByName(planetName) != null) {
JOptionPane.showMessageDialog(mwclient.getGUIClient().getMainFrame(),
"Planet with name " + planetName + " already exists.",
"Unable to create planet",
JOptionPane.WARNING_MESSAGE
);
} else {
mwclient.sendChat(GameHost.CAMPAIGN_PREFIX + "c admincreateplanet#"
+ planetName + "#" + xcoord + "#" + ycoord);
mwclient.refreshData();
mp.repaint();
int id = CampaignData.cd.getPlanetByName(planetName).getId();
new PlanetEditorDialog(mwclient, planetName, id);
}
}

mwclient.sendChat(GameHost.CAMPAIGN_PREFIX + "c admincreateplanet#"+planetName+"#"+xcoord+"#"+ycoord);
mwclient.refreshData();
mp.repaint();
int id = CampaignData.cd.getPlanetByName(planetName).getId();
new PlanetEditorDialog(mwclient, planetName, id);
}
});
if ( userLevel >= mwclient.getData().getAccessLevel("AdminCreatePlanet") )
Expand Down Expand Up @@ -200,4 +209,4 @@ public void actionPerformed(ActionEvent ex) {

}//end constructor

}//end AdminMapPopup
}//end AdminMapPopup
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
import mekwars.server.campaign.SHouse;
import mekwars.server.campaign.SPlanet;
import mekwars.server.campaign.commands.Command;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* @author Helge Richter
*
*/
public class AdminCreatePlanetCommand implements Command {
private static final Logger LOGGER = LogManager.getLogger(AdminCreatePlanetCommand.class);
int accessLevel = IAuthenticator.ADMIN;
String syntax = "Planet Name#Xcood#YCoord#";
public int getExecutionLevel(){return accessLevel;}
Expand All @@ -61,7 +62,13 @@ public void process(StringTokenizer command,String Username) {
HashMap<Integer,Integer> flu = new HashMap<Integer,Integer>();
flu.put(faction.getId(),100);
SPlanet planet = new SPlanet(PlanetName, new Influences(flu), 0, xcood, ycood);
CampaignMain.cm.addPlanet(planet);
try {
CampaignMain.cm.addPlanet(planet);
} catch (Exception exception) {
LOGGER.error("Unable to create planet", exception);
CampaignMain.cm.toUser("Unable to create planet " + planet, Username, true);
return;
}
planet.setOwner(null,faction,true);
planet.setOriginalOwner(faction.getName());
planet.updated();
Expand Down