Fix for faction creation sometimes causing an NPE; hopefully a fix for the cause of the null value as well, from an ID clash in the entity collection of factions
Fix for disband command causing an NPE if run from the console Additionally, disband command use is now logged
This commit is contained in:
parent
cace4aa955
commit
4ec086e4fa
@ -58,6 +58,13 @@ public class CmdCreate extends FCommand
|
|||||||
if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
||||||
|
|
||||||
Faction faction = Factions.i.create();
|
Faction faction = Factions.i.create();
|
||||||
|
|
||||||
|
if (faction == null)
|
||||||
|
{
|
||||||
|
msg("<b>There was an internal error while trying to create your faction. Please try again.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
faction.setTag(tag);
|
faction.setTag(tag);
|
||||||
fme.setRole(Role.ADMIN);
|
fme.setRole(Role.ADMIN);
|
||||||
fme.setFaction(faction);
|
fme.setFaction(faction);
|
||||||
|
@ -44,7 +44,7 @@ public class CmdDisband extends FCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ! Permission.DISBAND_ANY.has(me, true))
|
if ( ! Permission.DISBAND_ANY.has(sender, true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,8 @@ public class CmdDisband extends FCommand
|
|||||||
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
P.p.log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
|
||||||
|
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.shouldBeUsed())
|
||||||
{
|
{
|
||||||
//Give all the faction's money to the disbander
|
//Give all the faction's money to the disbander
|
||||||
|
@ -41,7 +41,7 @@ public class SpoutFeatures
|
|||||||
{
|
{
|
||||||
listenersHooked = true;
|
listenersHooked = true;
|
||||||
mainListener = new SpoutMainListener();
|
mainListener = new SpoutMainListener();
|
||||||
P.p.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, mainListener, Event.Priority.Normal, P.p);
|
P.p.registerEvent(Event.Type.CUSTOM_EVENT, mainListener, Event.Priority.Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -217,8 +217,13 @@ public abstract class EntityCollection<E extends Entity>
|
|||||||
|
|
||||||
public String getNextId()
|
public String getNextId()
|
||||||
{
|
{
|
||||||
this.nextId += 1;
|
String next = Integer.toString(this.nextId);
|
||||||
return "" + (nextId - 1);
|
do
|
||||||
|
{
|
||||||
|
this.nextId += 1;
|
||||||
|
} while ( ! isIdFree(Integer.toString(this.nextId)) );
|
||||||
|
|
||||||
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdFree(String id)
|
public boolean isIdFree(String id)
|
||||||
|
Loading…
Reference in New Issue
Block a user