nus-yam/ex-repair huggingface dataset:
Program: 18997
Project: 18997
Buggy source:
/** 
 * A Spout keypress event was received.
 * @param sp		The Spout player who pressed the key(s)
 * @param pressed	Represents the set of keys currently pressed
 * @return			True if a spout view was actually popped up or down, false otherwise
 */
public static boolean handleKeypress(SpoutPlayer sp,SMSSpoutKeyMap pressed){
  if (pressed.keysPressed() == 0)   return false;
  String s=pressed.toString();
  String viewName=keyMap.get(s);
  if (viewName != null) {
    if (SMSView.checkForView(viewName)) {
      try {
        SMSView v=SMSView.getView(viewName);
        if (v instanceof SMSSpoutView) {
          if (!PermissionUtils.isAllowedTo(sp,"String_Node_Str"))           return false;
          if (!v.hasOwnerPermission(sp))           return false;
          ((SMSSpoutView)v).toggleGUI(sp);
          return true;
        }
 else {
          LogUtils.warning("String_Node_Str" + v.getName() + "String_Node_Str"+ s);
        }
      }
 catch (      SMSException e) {
      }
    }
 else {
      keyMap.remove(s);
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * A Spout keypress event was received.
 * @param sp		The Spout player who pressed the key(s)
 * @param pressed	Represents the set of keys currently pressed
 * @return			True if a spout view was actually popped up or down, false otherwise
 */
public static boolean handleKeypress(SpoutPlayer sp,SMSSpoutKeyMap pressed){
  if (pressed.keysPressed() == 0)   return false;
  if (TextEntryPopup.hasActivePopup(sp.getName())) {
    return false;
  }
  String s=pressed.toString();
  String viewName=keyMap.get(s);
  if (viewName != null) {
    if (SMSView.checkForView(viewName)) {
      try {
        SMSView v=SMSView.getView(viewName);
        if (v instanceof SMSSpoutView) {
          if (!PermissionUtils.isAllowedTo(sp,"String_Node_Str"))           return false;
          if (!v.hasOwnerPermission(sp))           return false;
          ((SMSSpoutView)v).toggleGUI(sp);
          return true;
        }
 else {
          LogUtils.warning("String_Node_Str" + v.getName() + "String_Node_Str"+ s);
        }
      }
 catch (      SMSException e) {
      }
    }
 else {
      keyMap.remove(s);
    }
  }
  return false;
}
Program: 18998
Project: 18998
Buggy source:
@SuppressWarnings("String_Node_Str") private void giveBook(CommandSender sender,Player targetPlayer,String viewName,int amount){
  SMSView view=SMSView.getView(viewName);
  if (!(view instanceof PoppableView)) {
    throw new SMSException("String_Node_Str" + viewName + "String_Node_Str");
  }
  PopupBook book=new PopupBook(targetPlayer,view);
  ItemStack writtenbook=book.toItemStack();
  targetPlayer.getInventory().addItem(writtenbook);
  targetPlayer.updateInventory();
  String s=amount == 1 ? "String_Node_Str" : "String_Node_Str";
  MiscUtil.statusMessage(sender,String.format("String_Node_Str",amount,s,viewName,targetPlayer.getName()));
  if (sender != targetPlayer) {
    MiscUtil.statusMessage(targetPlayer,String.format("String_Node_Str",amount,s,view.getMenu().getTitle()));
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void giveBook(CommandSender sender,Player targetPlayer,String argStr,int amount){
  SMSView view;
  if (SMSView.checkForView(argStr)) {
    view=SMSView.getView(argStr);
    if (!(view instanceof PoppableView)) {
      throw new SMSException("String_Node_Str" + argStr + "String_Node_Str");
    }
  }
 else {
    SMSMenu menu=SMSMenu.getMenu(argStr);
    view=SMSView.findView(menu,PoppableView.class);
    if (view == null) {
      view=SMSInventoryView.addInventoryViewToMenu(menu);
    }
  }
  PopupBook book=new PopupBook(targetPlayer,view);
  ItemStack writtenbook=book.toItemStack();
  targetPlayer.getInventory().addItem(writtenbook);
  targetPlayer.updateInventory();
  String s=amount == 1 ? "String_Node_Str" : "String_Node_Str";
  MiscUtil.statusMessage(sender,String.format("String_Node_Str",amount,s,argStr,targetPlayer.getName()));
  if (sender != targetPlayer) {
    MiscUtil.statusMessage(targetPlayer,String.format("String_Node_Str",amount,s,view.getMenu().getTitle()));
  }
}
Program: 18999
Project: 18999
Buggy source:
@Override public boolean execute(Plugin plugin,CommandSender sender,String[] args){
  int amount=1;
  if (args.length >= 3) {
    try {
      amount=Math.min(64,Math.max(1,Integer.parseInt(args[2])));
    }
 catch (    NumberFormatException e) {
      throw new SMSException("String_Node_Str" + args[1] + "String_Node_Str");
    }
  }
  Player targetPlayer;
  if (args.length >= 4) {
    targetPlayer=Bukkit.getPlayer(args[3]);
    if (targetPlayer == null) {
      throw new SMSException("String_Node_Str" + args[3] + "String_Node_Str");
    }
  }
 else {
    notFromConsole(sender);
    targetPlayer=(Player)sender;
  }
  if (args[0].startsWith("String_Node_Str")) {
    short mapId;
    try {
      mapId=Short.parseShort(args[0]);
      giveMap(sender,targetPlayer,mapId,amount);
    }
 catch (    NumberFormatException e) {
      throw new SMSException("String_Node_Str" + args[0] + "String_Node_Str");
    }
  }
 else   if (args[0].startsWith("String_Node_Str")) {
    giveBook(sender,targetPlayer,args[1],amount);
  }
 else {
    showUsage(sender);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean execute(Plugin plugin,CommandSender sender,String[] args){
  int amount=1;
  if (args.length >= 3) {
    try {
      amount=Math.min(64,Math.max(1,Integer.parseInt(args[2])));
    }
 catch (    NumberFormatException e) {
      throw new SMSException("String_Node_Str" + args[1] + "String_Node_Str");
    }
  }
  Player targetPlayer;
  if (args.length >= 4) {
    targetPlayer=Bukkit.getPlayer(args[3]);
    if (targetPlayer == null) {
      throw new SMSException("String_Node_Str" + args[3] + "String_Node_Str");
    }
  }
 else {
    notFromConsole(sender);
    targetPlayer=(Player)sender;
  }
  if (args[0].startsWith("String_Node_Str")) {
    short mapId=getMapId(targetPlayer,args[1]);
    giveMap(sender,targetPlayer,mapId,amount);
  }
 else   if (args[0].startsWith("String_Node_Str")) {
    giveBook(sender,targetPlayer,args[1],amount);
  }
 else {
    showUsage(sender);
  }
  return true;
}
Program: 19000
Project: 19000
Buggy source:
/** 
 * Show the given player's GUI for this view.
 * @param p		The player object
 */
public void showGUI(Player p){
  SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  if (!popups.containsKey(sp.getName())) {
    popups.put(sp.getName(),new SpoutViewPopup(sp,this));
  }
  SpoutViewPopup gui=popups.get(sp.getName());
  activePopups.put(sp.getName(),gui);
  gui.popup();
}

Fixed version (ground truth):
/** 
 * Show the given player's GUI for this view.
 * @param p		The player object
 */
public void showGUI(Player p){
  SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  LogUtils.fine("String_Node_Str" + getName());
  if (!popups.containsKey(sp.getName())) {
    popups.put(sp.getName(),new SpoutViewPopup(sp,this));
  }
  SpoutViewPopup gui=popups.get(sp.getName());
  activePopups.put(sp.getName(),gui);
  gui.popup();
}
Program: 19001
Project: 19001
Buggy source:
/** 
 * Toggle the given player's visibility of the GUI for this view.  If a GUI for a different view is currently showing, pop that one down, and pop this one up.
 * @param p		The player object
 */
public void toggleGUI(Player p){
  final SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  if (hasActiveGUI(sp)) {
    SpoutViewPopup gui=getActiveGUI(sp);
    if (gui.getView() != this) {
      gui.getView().hideGUI(sp);
      Bukkit.getScheduler().scheduleSyncDelayedTask(ScrollingMenuSign.getInstance(),new Runnable(){
        @Override public void run(){
          showGUI(sp);
        }
      }
);
    }
 else {
      hideGUI(sp);
    }
  }
 else {
    showGUI(sp);
  }
}

Fixed version (ground truth):
/** 
 * Toggle the given player's visibility of the GUI for this view.  If a GUI for a different view is currently showing, pop that one down, and pop this one up.
 * @param p		The player object
 */
public void toggleGUI(Player p){
  final SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  if (hasActiveGUI(sp)) {
    SpoutViewPopup gui=getActiveGUI(sp);
    if (gui.getView() != this) {
      gui.getView().hideGUI(sp);
      Bukkit.getScheduler().scheduleSyncDelayedTask(ScrollingMenuSign.getInstance(),new Runnable(){
        @Override public void run(){
          showGUI(sp);
        }
      }
,3L);
    }
 else {
      hideGUI(sp);
    }
  }
 else {
    showGUI(sp);
  }
}
Program: 19002
Project: 19002
Buggy source:
/** 
 * Hide the given player's GUI for this view.
 * @param p		The player object
 */
public void hideGUI(Player p){
  SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  if (!popups.containsKey(sp.getName())) {
    return;
  }
  activePopups.remove(sp.getName());
  popups.get(sp.getName()).popdown();
}

Fixed version (ground truth):
/** 
 * Hide the given player's GUI for this view.
 * @param p		The player object
 */
public void hideGUI(Player p){
  SpoutPlayer sp=SpoutManager.getPlayer(p);
  if (!sp.isSpoutCraftEnabled())   return;
  if (!popups.containsKey(sp.getName()) || !activePopups.containsKey(sp.getName())) {
    return;
  }
  LogUtils.fine("String_Node_Str" + getName());
  activePopups.remove(sp.getName());
  popups.get(sp.getName()).popdown();
}
Program: 19003
Project: 19003
Buggy source:
@EventHandler public void onKeyPressedEvent(KeyPressedEvent event){
  SpoutPlayer player=event.getPlayer();
  SMSSpoutKeyMap pressed=getPressedKeys(player);
  if (event.getKey() == Keyboard.KEY_ESCAPE) {
    pressed.clear();
  }
 else {
    pressed.add(event.getKey());
  }
  if (event.getScreenType() != ScreenType.GAME_SCREEN && event.getScreenType() != ScreenType.CUSTOM_SCREEN)   return;
  try {
    if (TextEntryPopup.isPoppedUp(player)) {
      TextEntryPopup.handleKeypress(player,event.getKey());
      return;
    }
    if (SMSSpoutView.handleKeypress(player,pressed)) {
      return;
    }
    SMSView view=findViewForPlayer(player);
    if (view != null) {
      SMSUserAction action=getAction(pressed);
      LogUtils.fine("String_Node_Str" + pressed + "String_Node_Str"+ view.getName()+ "String_Node_Str"+ view.getMenu().getName()+ "String_Node_Str"+ action);
      action.execute(player,view);
    }
  }
 catch (  SMSException e) {
    MiscUtil.errorMessage(player,e.getMessage());
  }
catch (  IllegalStateException e) {
  }
}

Fixed version (ground truth):
@EventHandler public void onKeyPressedEvent(KeyPressedEvent event){
  SpoutPlayer player=event.getPlayer();
  SMSSpoutKeyMap pressed=getPressedKeys(player);
  if (event.getKey() == Keyboard.KEY_ESCAPE) {
    pressed.clear();
  }
 else {
    pressed.add(event.getKey());
  }
  if (event.getScreenType() != ScreenType.GAME_SCREEN && event.getScreenType() != ScreenType.CUSTOM_SCREEN)   return;
  PopupScreen s=player.getMainScreen().getActivePopup();
  if (s != null && !(s instanceof SMSGenericPopup))   return;
  try {
    if (TextEntryPopup.isPoppedUp(player)) {
      TextEntryPopup.handleKeypress(player,event.getKey());
      return;
    }
    if (SMSSpoutView.handleKeypress(player,pressed)) {
      return;
    }
    SMSView view=findViewForPlayer(player);
    if (view != null) {
      SMSUserAction action=getAction(pressed);
      LogUtils.fine("String_Node_Str" + pressed + "String_Node_Str"+ view.getName()+ "String_Node_Str"+ view.getMenu().getName()+ "String_Node_Str"+ action);
      action.execute(player,view);
    }
  }
 catch (  SMSException e) {
    MiscUtil.errorMessage(player,e.getMessage());
  }
catch (  IllegalStateException e) {
  }
}
Program: 19004
Project: 19004
Buggy source:
@Override public boolean execute(Plugin plugin,CommandSender sender,String[] args){
  SMSView view=null;
  if (args.length == 2 && args[0].equals("String_Node_Str")) {
    view=SMSView.getView(args[1]);
  }
 else   if (args.length == 2 && args[0].equals("String_Node_Str")) {
    try {
      view=SMSView.getViewForLocation(MiscUtil.parseLocation(args[0],sender));
    }
 catch (    IllegalArgumentException e) {
      throw new SMSException(e.getMessage());
    }
    view=SMSView.getViewForLocation(MiscUtil.parseLocation(args[0],sender));
  }
 else   if (sender instanceof Player && (view=SMSMapView.getHeldMapView((Player)sender)) != null) {
  }
 else   if (args.length == 0) {
    notFromConsole(sender);
    try {
      Block b=((Player)sender).getTargetBlock(null,3);
      view=SMSView.getViewForLocation(b.getLocation());
    }
 catch (    IllegalStateException e) {
    }
  }
  if (view == null) {
    throw new SMSException("String_Node_Str");
  }
 else {
    PermissionUtils.requirePerms(sender,"String_Node_Str" + view.getType());
    view.deletePermanent();
    MiscUtil.statusMessage(sender,String.format("String_Node_Str",view.getType(),view.getName(),view.getMenu().getName()));
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean execute(Plugin plugin,CommandSender sender,String[] args){
  SMSView view=null;
  if (args.length == 2 && args[0].equals("String_Node_Str")) {
    view=SMSView.getView(args[1]);
  }
 else   if (args.length == 2 && args[0].equals("String_Node_Str")) {
    try {
      view=SMSView.getViewForLocation(MiscUtil.parseLocation(args[1],sender));
    }
 catch (    IllegalArgumentException e) {
      throw new SMSException(e.getMessage());
    }
  }
 else   if (sender instanceof Player && (view=SMSMapView.getHeldMapView((Player)sender)) != null) {
  }
 else   if (args.length == 0) {
    notFromConsole(sender);
    try {
      Block b=((Player)sender).getTargetBlock(null,3);
      view=SMSView.getViewForLocation(b.getLocation());
    }
 catch (    IllegalStateException e) {
    }
  }
  if (view == null) {
    throw new SMSException("String_Node_Str");
  }
 else {
    PermissionUtils.requirePerms(sender,"String_Node_Str" + view.getType());
    view.deletePermanent();
    MiscUtil.statusMessage(sender,String.format("String_Node_Str",view.getType(),view.getName(),view.getMenu().getName()));
  }
  return true;
}
Program: 19005
Project: 19005
Buggy source:
/** 
 * Check if the player can afford to pay the costs.
 * @param player
 * @param costs
 * @return	True if the costs are affordable, false otherwise
 */
public static boolean playerCanAfford(Player player,List<Cost> costs){
  if (player == null) {
    return true;
  }
  for (  Cost c : costs) {
    if (c.getQuantity() <= 0)     continue;
switch (c.getType()) {
case MONEY:
      if (ScrollingMenuSign.economy == null) {
        return true;
      }
    if (ScrollingMenuSign.economy.getBalance(player.getName()) < c.getQuantity()) {
      return false;
    }
  break;
case ITEM:
HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
int remainingCheck=(int)c.getQuantity();
for (Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
remainingCheck-=entry.getValue().getAmount();
if (remainingCheck <= 0) break;
}
}
if (remainingCheck > 0) {
return false;
}
break;
case EXPERIENCE:
if (player.getTotalExperience() < c.getQuantity()) return false;
break;
case FOOD:
if (player.getFoodLevel() <= c.getQuantity()) return false;
break;
case HEALTH:
if (player.getHealth() <= c.getQuantity()) return false;
break;
}
}
return true;
}

Fixed version (ground truth):
/** 
 * Check if the player can afford to pay the costs.
 * @param player
 * @param costs
 * @return	True if the costs are affordable, false otherwise
 */
public static boolean playerCanAfford(Player player,List<Cost> costs){
  if (player == null) {
    return true;
  }
  for (  Cost c : costs) {
    if (c.getQuantity() <= 0)     continue;
switch (c.getType()) {
case MONEY:
      if (ScrollingMenuSign.economy == null) {
        return true;
      }
    if (ScrollingMenuSign.economy.getBalance(player.getName()) < c.getQuantity()) {
      return false;
    }
  break;
case ITEM:
HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
int remainingCheck=(int)c.getQuantity();
for (Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
remainingCheck-=entry.getValue().getAmount();
if (remainingCheck <= 0) break;
}
}
if (remainingCheck > 0) {
return false;
}
break;
case EXPERIENCE:
ExperienceManager em=new ExperienceManager(player);
if (em.getCurrentExp() < c.getQuantity()) return false;
break;
case FOOD:
if (player.getFoodLevel() <= c.getQuantity()) return false;
break;
case HEALTH:
if (player.getHealth() <= c.getQuantity()) return false;
break;
}
}
return true;
}
Program: 19006
Project: 19006
Buggy source:
@Override public boolean execute(ScrollingMenuSign plugin,Player player,String[] args){
  Level l=SMSLogger.getLogLevel();
  if (l.intValue() > Level.INFO.intValue()) {
    SMSLogger.setLogLevel(Level.INFO);
  }
 else {
    SMSLogger.setLogLevel(Level.FINE);
  }
  MiscUtil.statusMessage(player,"String_Node_Str" + SMSLogger.getLogLevel());
  MiscUtil.statusMessage(player,"String_Node_Str");
  return true;
}

Fixed version (ground truth):
@Override public boolean execute(ScrollingMenuSign plugin,Player player,String[] args) throws SMSException {
  Level l=SMSLogger.getLogLevel();
  if (l.intValue() < Level.INFO.intValue()) {
    SMSConfig.setPluginConfiguration("String_Node_Str","String_Node_Str");
  }
 else {
    SMSConfig.setPluginConfiguration("String_Node_Str","String_Node_Str");
  }
  MiscUtil.statusMessage(player,"String_Node_Str" + SMSLogger.getLogLevel());
  MiscUtil.statusMessage(player,"String_Node_Str");
  return true;
}
Program: 19007
Project: 19007
Buggy source:
/** 
 * Sets the scroll position for the given player on this view.
 * @param playerName	The player's name
 * @param scrollPos		The scroll position
 */
public void setScrollPos(String playerName,int scrollPos){
  playerScrollPos.put(playerName,scrollPos);
  lastScrollPos=scrollPos;
  setDirty(playerName,true);
}

Fixed version (ground truth):
/** 
 * Sets the scroll position for the given player on this view.
 * @param playerName	The player's name
 * @param scrollPos		The scroll position
 */
public void setScrollPos(String playerName,int scrollPos){
  if (perPlayerScrolling) {
    playerScrollPos.put(playerName,scrollPos);
    lastScrollPos=scrollPos;
    setDirty(playerName,true);
  }
 else {
    lastScrollPos=scrollPos;
    setDirty(true);
  }
}
Program: 19008
Project: 19008
Buggy source:
public SMSScrollableView(String name,SMSMenu menu){
  super(name,menu);
  lastScrollPos=1;
  wrap=true;
}

Fixed version (ground truth):
public SMSScrollableView(String name,SMSMenu menu){
  super(name,menu);
  lastScrollPos=1;
  wrap=true;
  perPlayerScrolling=true;
}
Program: 19009
Project: 19009
Buggy source:
/** 
 * Get the given player's scroll position (currently-selected item) for this view.  If the scroll position is out of range (possibly because an item was deleted from the menu), it will be automatically adjusted to be in range before being returned.
 * @param playerName	The player to check
 * @return				The scroll position
 */
public int getScrollPos(String playerName){
  if (!playerScrollPos.containsKey(playerName) || playerScrollPos.get(playerName) < 1) {
    setScrollPos(playerName,1);
  }
 else   if (playerScrollPos.get(playerName) > getMenu().getItemCount())   setScrollPos(playerName,getMenu().getItemCount());
  return playerScrollPos.get(playerName);
}

Fixed version (ground truth):
/** 
 * Get the given player's scroll position (currently-selected item) for this view.  If the scroll position is out of range (possibly because an item was deleted from the menu), it will be automatically adjusted to be in range before being returned.
 * @param playerName	The player to check
 * @return				The scroll position
 */
public int getScrollPos(String playerName){
  if (perPlayerScrolling) {
    if (!playerScrollPos.containsKey(playerName) || playerScrollPos.get(playerName) < 1) {
      setScrollPos(playerName,1);
    }
 else     if (playerScrollPos.get(playerName) > getMenu().getItemCount())     setScrollPos(playerName,getMenu().getItemCount());
    return playerScrollPos.get(playerName);
  }
 else {
    return getLastScrollPos();
  }
}
Program: 19010
Project: 19010
Buggy source:
/** 
 * Create a new sign view object.
 * @param name	Unique name for this view.
 * @param menu	The SMSMenu object to attach this view to.
 * @param loc	The location of this view's sign
 * @throws SMSException	if the given location is not suitable for this view
 */
public SMSSignView(String name,SMSMenu menu,Location loc) throws SMSException {
  super(name,menu);
  addLocation(loc);
}

Fixed version (ground truth):
/** 
 * Create a new sign view object.  Equivalent to calling SMSSignView(null, menu, loc).  The view's name will be automatically generated, based on the menu name.
 * @param menu	The SMSMenu object to attach this view to.
 * @param loc	The location of this view's sign
 * @throws SMSException	if the given location is not suitable for this view
 */
public SMSSignView(SMSMenu menu,Location loc) throws SMSException {
  this(null,menu,loc);
}
Program: 19012
Project: 19012
Buggy source:
static void init(ScrollingMenuSign plugin){
  SMSConfig.plugin=plugin;
  if (plugin != null) {
    pluginDir=plugin.getDataFolder();
  }
  setupDirectoryStructure();
  initConfigFile();
}

Fixed version (ground truth):
static void init(ScrollingMenuSign plugin){
  setupDirectoryStructure();
  initConfigFile();
}
Program: 19013
Project: 19013
Buggy source:
public static void setConfigItem(Player player,String key,List<String> list) throws SMSException {
  if (!key.startsWith("String_Node_Str")) {
    key="String_Node_Str" + key;
  }
  if (getConfig().getDefaults().get(key) == null) {
    throw new SMSException("String_Node_Str" + key + "String_Node_Str");
  }
  if (!(getConfig().getDefaults().get(key) instanceof List<?>))   throw new SMSException("String_Node_Str" + key + "String_Node_Str");
  handleListValue(key,list);
  plugin.saveConfig();
}

Fixed version (ground truth):
public static void setConfigItem(Player player,String key,List<String> list) throws SMSException {
  if (!key.startsWith("String_Node_Str")) {
    key="String_Node_Str" + key;
  }
  if (getConfig().getDefaults().get(key) == null) {
    throw new SMSException("String_Node_Str" + key + "String_Node_Str");
  }
  if (!(getConfig().getDefaults().get(key) instanceof List<?>))   throw new SMSException("String_Node_Str" + key + "String_Node_Str");
  handleListValue(key,list);
  ScrollingMenuSign.getInstance().saveConfig();
}
Program: 19014
Project: 19014
Buggy source:
public static Configuration getConfig(){
  return plugin.getConfig();
}

Fixed version (ground truth):
public static Configuration getConfig(){
  return ScrollingMenuSign.getInstance().getConfig();
}
Program: 19015
Project: 19015
Buggy source:
private static void initConfigFile(){
  Boolean saveNeeded=false;
  plugin.getConfig().options().copyDefaults(true);
  Configuration config=plugin.getConfig();
  for (  String k : getConfig().getDefaults().getKeys(true)) {
    if (!config.contains(k)) {
      saveNeeded=true;
    }
  }
  if (config.getString("String_Node_Str").equals("String_Node_Str")) {
    config.set("String_Node_Str","String_Node_Str");
    saveNeeded=true;
  }
  @SuppressWarnings("String_Node_Str") List<String> nodeList=config.getList("String_Node_Str");
  if (nodeList.size() == 1 && nodeList.get(0).equals(SAMPLE_NODE)) {
    String user=getConfig().getString("String_Node_Str","String_Node_Str");
    List<String> nodes=PermissionsUtils.getPermissionNodes(user,null);
    getConfig().set("String_Node_Str",nodes);
    MiscUtil.log(Level.INFO,"String_Node_Str" + nodes.size() + "String_Node_Str"+ user+ "String_Node_Str");
    saveNeeded=true;
  }
  if (saveNeeded)   plugin.saveConfig();
}

Fixed version (ground truth):
private static void initConfigFile(){
  Boolean saveNeeded=false;
  ScrollingMenuSign.getInstance().getConfig().options().copyDefaults(true);
  Configuration config=ScrollingMenuSign.getInstance().getConfig();
  for (  String k : getConfig().getDefaults().getKeys(true)) {
    if (!config.contains(k)) {
      saveNeeded=true;
    }
  }
  if (config.getString("String_Node_Str").equals("String_Node_Str")) {
    config.set("String_Node_Str","String_Node_Str");
    saveNeeded=true;
  }
  @SuppressWarnings("String_Node_Str") List<String> nodeList=config.getList("String_Node_Str");
  if (nodeList.size() == 1 && nodeList.get(0).equals(SAMPLE_NODE)) {
    String user=getConfig().getString("String_Node_Str","String_Node_Str");
    List<String> nodes=PermissionsUtils.getPermissionNodes(user,null);
    getConfig().set("String_Node_Str",nodes);
    MiscUtil.log(Level.INFO,"String_Node_Str" + nodes.size() + "String_Node_Str"+ user+ "String_Node_Str");
    saveNeeded=true;
  }
  if (saveNeeded)   ScrollingMenuSign.getInstance().saveConfig();
}
Program: 19016
Project: 19016
Buggy source:
private static void setupDirectoryStructure(){
  commandFile=new File(pluginDir,commandFileName);
  dataDir=new File(pluginDir,dataDirName);
  menusDir=new File(dataDir,menusDirName);
  viewsDir=new File(dataDir,viewsDirName);
  macrosDir=new File(dataDir,macrosDirName);
  createDirectory(pluginDir);
  createDirectory(dataDir);
  createDirectory(menusDir);
  createDirectory(viewsDir);
  createDirectory(macrosDir);
}

Fixed version (ground truth):
private static void setupDirectoryStructure(){
  pluginDir=ScrollingMenuSign.getInstance().getDataFolder();
  commandFile=new File(pluginDir,commandFileName);
  dataDir=new File(pluginDir,dataDirName);
  menusDir=new File(dataDir,menusDirName);
  viewsDir=new File(dataDir,viewsDirName);
  macrosDir=new File(dataDir,macrosDirName);
  createDirectory(pluginDir);
  createDirectory(dataDir);
  createDirectory(menusDir);
  createDirectory(viewsDir);
  createDirectory(macrosDir);
}
Program: 19017
Project: 19017
Buggy source:
/** 
 * Executes the command for this item
 * @param player		Player to execute the command for
 * @throws SMSException	if the usage limit for this player is exhausted
 */
public void execute(Player player) throws SMSException {
  checkRemainingUses(this.getUseLimits(),player);
  checkRemainingUses(menu.getUseLimits(),player);
  String cmd=getCommand();
  if ((cmd == null || cmd.isEmpty()) && !menu.getDefaultCommand().isEmpty()) {
    cmd=menu.getDefaultCommand().replaceAll("String_Node_Str",getLabel());
  }
  ReturnStatus rs=new CommandParser().runCommandString(player,command);
switch (rs) {
case NO_PERMS:
    MiscUtil.errorMessage(player,"String_Node_Str");
  break;
case CANT_AFFORD:
MiscUtil.errorMessage(player,"String_Node_Str");
break;
case CMD_FAILED:
MiscUtil.errorMessage(player,"String_Node_Str" + command + "String_Node_Str");
break;
case WOULD_RECURSE:
MiscUtil.errorMessage(player,"String_Node_Str" + command);
break;
case BAD_MACRO:
MiscUtil.errorMessage(player,"String_Node_Str" + command);
break;
}
}

Fixed version (ground truth):
/** 
 * Executes the command for this item
 * @param player		Player to execute the command for
 * @throws SMSException	if the usage limit for this player is exhausted
 */
public void execute(Player player) throws SMSException {
  checkRemainingUses(this.getUseLimits(),player);
  checkRemainingUses(menu.getUseLimits(),player);
  String cmd=getCommand();
  if ((cmd == null || cmd.isEmpty()) && !menu.getDefaultCommand().isEmpty()) {
    cmd=menu.getDefaultCommand().replaceAll("String_Node_Str",getLabel());
  }
  ReturnStatus rs=new CommandParser().runCommandString(player,cmd);
switch (rs) {
case NO_PERMS:
    MiscUtil.errorMessage(player,"String_Node_Str");
  break;
case CANT_AFFORD:
MiscUtil.errorMessage(player,"String_Node_Str");
break;
case CMD_FAILED:
MiscUtil.errorMessage(player,"String_Node_Str" + command + "String_Node_Str");
break;
case WOULD_RECURSE:
MiscUtil.errorMessage(player,"String_Node_Str" + cmd);
break;
case BAD_MACRO:
MiscUtil.errorMessage(player,"String_Node_Str" + cmd);
break;
}
}
Program: 19019
Project: 19019
Buggy source:
@Override public void onDisable(){
  SMSPersistence.saveMenusAndViews();
  SMSPersistence.saveMacros();
  MiscUtil.log(Level.INFO,description.getName() + "String_Node_Str" + description.getVersion()+ "String_Node_Str");
}

Fixed version (ground truth):
@Override public void onDisable(){
  SMSPersistence.saveMenusAndViews();
  SMSPersistence.saveMacros();
  MiscUtil.log(Level.INFO,getDescription().getName() + "String_Node_Str" + getDescription().getVersion()+ "String_Node_Str");
}
Program: 19020
Project: 19020
Buggy source:
/** 
 * Display the specified page for the player.
 * @param player The player
 * @param pageNum The page number to display
 */
public static void showPage(Player player,int pageNum){
  if (!bufferMap.containsKey(name(player))) {
    return;
  }
  if (getSize(player) == 0)   return;
  if (player != null) {
    if (pageNum < 1 || pageNum > getPageCount(player)) {
      throw new IllegalArgumentException("String_Node_Str" + pageNum + "String_Node_Str");
    }
    int nMessages=getSize(player);
    int i=(pageNum - 1) * pageSize;
    String header=String.format("String_Node_Str",i + 1,Math.min(pageNum * pageSize,nMessages),nMessages,pageNum,getPageCount(player));
    MiscUtil.statusMessage(player,ChatColor.GREEN + MinecraftChatStr.strPadCenterChat(header,310,'-'));
    for (; i < nMessages && i < pageNum * pageSize; ++i) {
      MiscUtil.statusMessage(player,getLine(player,i));
    }
    String footer="String_Node_Str";
    if (nMessages > pageSize * pageNum && pageCmd != null) {
      footer="String_Node_Str" + pageCmd + "String_Node_Str";
    }
    MiscUtil.statusMessage(player,ChatColor.GREEN + MinecraftChatStr.strPadCenterChat(footer,310,'-'));
    setPage(player,pageNum);
  }
 else {
    for (    String s : bufferMap.get(name(player))) {
      MiscUtil.statusMessage(null,ChatColor.stripColor(MiscUtil.parseColourSpec(s)));
    }
  }
}

Fixed version (ground truth):
/** 
 * Display the specified page for the player.
 * @param player The player
 * @param pageNum The page number to display
 */
public static void showPage(Player player,int pageNum){
  if (!bufferMap.containsKey(name(player))) {
    return;
  }
  if (getSize(player) == 0)   return;
  if (player != null) {
    if (pageNum < 1 || pageNum > getPageCount(player)) {
      throw new IllegalArgumentException("String_Node_Str" + pageNum + "String_Node_Str");
    }
    int nMessages=getSize(player);
    int i=(pageNum - 1) * pageSize;
    String header=String.format("String_Node_Str",i + 1,Math.min(pageNum * pageSize,nMessages),nMessages,pageNum,getPageCount(player));
    MiscUtil.statusMessage(player,ChatColor.GREEN + MinecraftChatStr.strPadCenterChat(header,310,'-'));
    for (; i < nMessages && i < pageNum * pageSize; ++i) {
      MiscUtil.statusMessage(player,getLine(player,i));
    }
    String footer="String_Node_Str";
    if (nMessages > pageSize * pageNum && pageCmd != null) {
      footer="String_Node_Str" + pageCmd + "String_Node_Str";
    }
    MiscUtil.statusMessage(player,ChatColor.GREEN + MinecraftChatStr.strPadCenterChat(footer,310,'-'));
    setPage(player,pageNum);
  }
 else {
    List<String> buffer=bufferMap.get(name(player));
    if (buffer != null) {
      for (      String s : buffer) {
        MiscUtil.statusMessage(null,ChatColor.stripColor(MiscUtil.parseColourSpec(s)));
      }
    }
  }
}
Program: 19021
Project: 19021
Buggy source:
public static void log(Level level,String message,Exception err){
  if (err == null) {
    log(level,message);
  }
 else {
    logger.log(level,String.format(messageFormat,message == null ? (err == null ? "String_Node_Str" : err.getMessage()) : message),err);
  }
}

Fixed version (ground truth):
public static void log(Level level,String message,Exception err){
  if (err == null) {
    log(level,message);
  }
 else {
    logger.log(level,String.format(messageFormat,message == null ? err.getMessage() : message),err);
  }
}
Program: 19022
Project: 19022
Buggy source:
public void debug(String message,int level){
  if (debuggers.keySet().size() == 0)   return;
  for (  String name : debuggers.keySet()) {
    if (level >= debuggers.get(name)) {
      if (name.equals("String_Node_Str")) {
        debugMessage(null,message);
      }
 else {
        Player p=Bukkit.getServer().getPlayer(name);
        if (p != null) {
          debugMessage(p,message);
        }
 else {
          removeDebugger(p);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void debug(String message,int level){
  if (debuggers.keySet().size() == 0)   return;
  for (  String name : debuggers.keySet()) {
    if (level >= debuggers.get(name)) {
      if (name.equals(CONSOLE)) {
        debugMessage(null,message);
      }
 else {
        Player p=Bukkit.getServer().getPlayer(name);
        if (p != null) {
          debugMessage(p,message);
        }
 else {
          removeDebugger(name);
        }
      }
    }
  }
}
Program: 19023
Project: 19023
Buggy source:
public void removeDebugger(Player p){
  debuggers.remove(debuggerName(p));
}

Fixed version (ground truth):
private void removeDebugger(String name){
  debuggers.remove(name);
}
Program: 19024
Project: 19024
Buggy source:
private String debuggerName(Player p){
  String name;
  if (p == null) {
    name="String_Node_Str";
  }
 else {
    name=p.getName();
  }
  return name;
}

Fixed version (ground truth):
private static String debuggerName(Player p){
  return p == null ? CONSOLE : p.getName();
}
Program: 19025
Project: 19025
Buggy source:
/** 
 * Get a list of the players affected by this view during an execution event.  Returns null if this view doesn't affect players (PLAYERRADIUS <= 0), or a list of players (which may be empty) otherwise.  If AFFECTONLYNEAREST is true, then the list will contain one element only - the closest player to the view.
 * @return	A list of affected players
 */
private List<Player> getAffectedPlayers(Location loc){
  Double radius=(Double)getAttribute(PLAYERRADIUS);
  if (radius <= 0) {
    return null;
  }
  if (getLocations().isEmpty()) {
    return null;
  }
  double minDist=Double.MAX_VALUE;
  List<Player> res=new ArrayList<Player>();
  if ((Boolean)getAttribute(AFFECTONLYNEAREST)) {
    Player closest=null;
    for (    Player p : loc.getWorld().getPlayers()) {
      double dist=p.getLocation().distance(loc);
      if (dist < radius && dist < minDist) {
        closest=p;
        minDist=dist;
      }
      res.add(closest);
    }
  }
 else {
    for (    Player p : loc.getWorld().getPlayers()) {
      double dist=p.getLocation().distance(loc);
      if (dist < radius) {
        res.add(p);
      }
    }
  }
  return res;
}

Fixed version (ground truth):
/** 
 * Get a list of the players affected by this view during an execution event.  Returns null if this view doesn't affect players (PLAYERRADIUS <= 0), or a list of players (which may be empty) otherwise.  If AFFECTONLYNEAREST is true, then the list will contain one element only - the closest player to the view.
 * @param loc The view's location - where the event occurred
 * @return	A list of affected players
 */
private List<Player> getAffectedPlayers(Location loc){
  Double radius=(Double)getAttribute(PLAYERRADIUS);
  if (radius <= 0) {
    return null;
  }
  double minDist=Double.MAX_VALUE;
  List<Player> res=new ArrayList<Player>();
  if ((Boolean)getAttribute(AFFECTONLYNEAREST)) {
    Player closest=null;
    for (    Player p : loc.getWorld().getPlayers()) {
      double dist=p.getLocation().distance(loc);
      if (dist < radius && dist < minDist) {
        closest=p;
        minDist=dist;
      }
    }
    if (closest != null) {
      res.add(closest);
    }
  }
 else {
    for (    Player p : loc.getWorld().getPlayers()) {
      double dist=p.getLocation().distance(loc);
      if (dist < radius) {
        res.add(p);
      }
    }
  }
  return res;
}
Program: 19026
Project: 19026
Buggy source:
/** 
 * Executes the command for this item
 * @param player		Player to execute the command for
 * @throws SMSException	if the usage limit for this player is exhausted
 */
public void execute(Player player) throws SMSException {
  if (player != null) {
    checkRemainingUses(this.getUseLimits(),player);
    checkRemainingUses(menu.getUseLimits(),player);
  }
  String cmd=getCommand();
  if ((cmd == null || cmd.isEmpty()) && !menu.getDefaultCommand().isEmpty()) {
    cmd=menu.getDefaultCommand().replaceAll("String_Node_Str",getLabel());
  }
  ParsedCommand pCmd=new CommandParser().runCommand(player,cmd);
switch (pCmd.getStatus()) {
case NO_PERMS:
    MiscUtil.errorMessage(player,"String_Node_Str");
  break;
case CANT_AFFORD:
MiscUtil.errorMessage(player,"String_Node_Str");
break;
case CMD_FAILED:
MiscUtil.errorMessage(player,"String_Node_Str" + command + "String_Node_Str");
break;
case WOULD_RECURSE:
MiscUtil.errorMessage(player,"String_Node_Str" + cmd);
break;
case BAD_MACRO:
MiscUtil.errorMessage(player,"String_Node_Str" + cmd);
break;
}
}

Fixed version (ground truth):
/** 
 * Executes the command for this item
 * @param player		Player to execute the command for
 * @throws SMSException	if the usage limit for this player is exhausted
 */
public void execute(Player player) throws SMSException {
  if (player != null) {
    checkRemainingUses(this.getUseLimits(),player);
    checkRemainingUses(menu.getUseLimits(),player);
  }
  String cmd=getCommand();
  if ((cmd == null || cmd.isEmpty()) && !menu.getDefaultCommand().isEmpty()) {
    cmd=menu.getDefaultCommand().replaceAll("String_Node_Str",getLabel());
  }
  ParsedCommand pCmd=new CommandParser().runCommand(player,cmd);
  if (pCmd.getStatus() != ReturnStatus.CMD_OK) {
    MiscUtil.errorMessage(player,pCmd.getLastError());
  }
}
Program: 19028
Project: 19028
Buggy source:
/** 
 * Parse and run a command string via the SMS command engine
 * @param player	Player who is running the command
 * @param command	Command to be run
 * @return			A return status indicating the outcome of the command
 * @throws SMSException
 * @deprecated use runCommand()	
 */
@Deprecated public ReturnStatus runCommandString(Player player,String command) throws SMSException {
  ParsedCommand cmd=handleCommandString(player,command,RunMode.EXECUTE);
  if (cmd == null) {
    return ReturnStatus.CMD_OK;
  }
  if (!cmd.isAffordable())   cmd.setStatus(ReturnStatus.CANT_AFFORD);
  return cmd.getStatus();
}

Fixed version (ground truth):
/** 
 * Parse and run a command string via the SMS command engine
 * @param player	Player who is running the command
 * @param command	Command to be run
 * @return			A return status indicating the outcome of the command
 * @throws SMSException
 * @deprecated use runCommand()	
 */
@Deprecated public ReturnStatus runCommandString(Player player,String command) throws SMSException {
  ParsedCommand cmd=runCommand(player,command);
  return cmd.getStatus();
}
Program: 19031
Project: 19031
Buggy source:
/** 
 * Take items from a player's inventory.  Doesn't check to see if there is enough - use playerCanAfford() for that.
 * @param player
 * @param c
 */
private static void chargeItems(Player player,Cost c){
  HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
  int remainingCheck=c.getQuantity();
  System.out.println("String_Node_Str" + remainingCheck);
  for (  Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
    if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
      remainingCheck-=entry.getValue().getAmount();
      if (remainingCheck < 0) {
        entry.getValue().setAmount(-remainingCheck);
        break;
      }
 else       if (remainingCheck == 0) {
        player.getInventory().removeItem(entry.getValue());
        break;
      }
 else {
        player.getInventory().removeItem(entry.getValue());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Take items from a player's inventory.  Doesn't check to see if there is enough - use playerCanAfford() for that.
 * @param player
 * @param c
 */
private static void chargeItems(Player player,Cost c){
  HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
  int remainingCheck=c.getQuantity();
  for (  Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
    if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
      remainingCheck-=entry.getValue().getAmount();
      if (remainingCheck < 0) {
        entry.getValue().setAmount(-remainingCheck);
        break;
      }
 else       if (remainingCheck == 0) {
        player.getInventory().removeItem(entry.getValue());
        break;
      }
 else {
        player.getInventory().removeItem(entry.getValue());
      }
    }
  }
}
Program: 19032
Project: 19032
Buggy source:
public static void setConfigItem(Player player,String key,String val) throws SMSException {
  if (key.length() < 5 || !key.substring(0,4).equals("String_Node_Str")) {
    key="String_Node_Str" + key;
  }
  if (configDefaults.get(key) == null) {
    throw new SMSException("String_Node_Str" + key);
  }
  if (configDefaults.get(key) instanceof Boolean) {
    Boolean bVal=false;
    if (val.equals("String_Node_Str") || val.equals("String_Node_Str")) {
      bVal=false;
    }
 else     if (val.equals("String_Node_Str") || val.equals("String_Node_Str")) {
      bVal=true;
    }
 else {
      MiscUtil.errorMessage(player,"String_Node_Str" + val + "String_Node_Str");
      return;
    }
    getConfiguration().setProperty(key,bVal);
  }
 else   if (configDefaults.get(key) instanceof Integer) {
    try {
      int nVal=Integer.parseInt(val);
      getConfiguration().setProperty(key,nVal);
    }
 catch (    NumberFormatException e) {
      MiscUtil.errorMessage(player,"String_Node_Str" + val);
    }
  }
 else {
    getConfiguration().setProperty(key,val);
  }
  getConfiguration().save();
}

Fixed version (ground truth):
public static void setConfigItem(Player player,String key,String val) throws SMSException {
  if (!key.startsWith("String_Node_Str")) {
    key="String_Node_Str" + key;
  }
  if (configDefaults.get(key) == null) {
    throw new SMSException("String_Node_Str" + key);
  }
  if (configDefaults.get(key) instanceof Boolean) {
    Boolean bVal=false;
    if (val.equalsIgnoreCase("String_Node_Str") || val.equalsIgnoreCase("String_Node_Str")) {
      bVal=false;
    }
 else     if (val.equalsIgnoreCase("String_Node_Str") || val.equalsIgnoreCase("String_Node_Str")) {
      bVal=true;
    }
 else {
      MiscUtil.errorMessage(player,"String_Node_Str" + val + "String_Node_Str");
      return;
    }
    getConfiguration().setProperty(key,bVal);
  }
 else   if (configDefaults.get(key) instanceof Integer) {
    try {
      int nVal=Integer.parseInt(val);
      getConfiguration().setProperty(key,nVal);
    }
 catch (    NumberFormatException e) {
      throw new SMSException("String_Node_Str" + val);
    }
  }
 else {
    getConfiguration().setProperty(key,val);
  }
  getConfiguration().save();
}
Program: 19033
Project: 19033
Buggy source:
/** 
 * Take items from a player's inventory.  Doesn't check to see if there is enough - use playerCanAfford() for that.
 * @param player
 * @param c
 */
private static void chargeItems(Player player,Cost c){
  HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
  int remainingCheck=c.getQuantity();
  for (  Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
    if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
      remainingCheck-=entry.getValue().getAmount();
      if (remainingCheck <= 0) {
        if (remainingCheck == 0)         player.getInventory().remove(entry.getValue());
 else         entry.getValue().setAmount(-remainingCheck);
        break;
      }
 else {
        player.getInventory().remove(entry.getValue());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Take items from a player's inventory.  Doesn't check to see if there is enough - use playerCanAfford() for that.
 * @param player
 * @param c
 */
private static void chargeItems(Player player,Cost c){
  HashMap<Integer,? extends ItemStack> matchingInvSlots=player.getInventory().all(Material.getMaterial(c.getId()));
  int remainingCheck=c.getQuantity();
  System.out.println("String_Node_Str" + remainingCheck);
  for (  Entry<Integer,? extends ItemStack> entry : matchingInvSlots.entrySet()) {
    if (c.getData() == null || (entry.getValue().getData() != null && entry.getValue().getData().getData() == c.getData())) {
      remainingCheck-=entry.getValue().getAmount();
      if (remainingCheck < 0) {
        entry.getValue().setAmount(-remainingCheck);
        break;
      }
 else       if (remainingCheck == 0) {
        player.getInventory().removeItem(entry.getValue());
        break;
      }
 else {
        player.getInventory().removeItem(entry.getValue());
      }
    }
  }
}
Program: 19036
Project: 19036
Buggy source:
Cost(String costSpec){
  System.out.println("String_Node_Str" + costSpec);
  String[] s1=costSpec.split("String_Node_Str");
  if (s1.length != 2)   throw new IllegalArgumentException("String_Node_Str");
  String[] s2=s1[0].split("String_Node_Str");
  if (s2.length < 1 || s2.length > 2)   throw new IllegalArgumentException("String_Node_Str");
  id=Integer.parseInt(s2[0]);
  data=s2.length == 2 ? Byte.parseByte(s2[1]) : null;
  quantity=Integer.parseInt(s1[1]);
}

Fixed version (ground truth):
Cost(String costSpec){
  String[] s1=costSpec.split("String_Node_Str");
  if (s1.length != 2)   throw new IllegalArgumentException("String_Node_Str");
  String[] s2=s1[0].split("String_Node_Str");
  if (s2.length < 1 || s2.length > 2)   throw new IllegalArgumentException("String_Node_Str");
  id=Integer.parseInt(s2[0]);
  data=s2.length == 2 ? Byte.parseByte(s2[1]) : null;
  quantity=Integer.parseInt(s1[1]);
}
Program: 19038
Project: 19038
Buggy source:
/** 
 * Associate this view with a map ID.  Removes (and saves) all renderers currently on the map, and adds our own SMSRenderer to the map.
 * @param id
 */
public void setMapId(short id){
  mapView=Bukkit.getServer().getMap(id);
  for (  MapRenderer r : mapView.getRenderers()) {
    previousRenderers.add(r);
    mapView.removeRenderer(r);
  }
  mapView.addRenderer(getMapRenderer());
  allMapViews.put(mapView.getId(),this);
  autosave();
}

Fixed version (ground truth):
/** 
 * Associate this view with a map ID.  Removes (and saves) all renderers currently on the map, and adds our own SMSRenderer to the map.
 * @param id
 */
public void setMapId(short id){
  mapView=Bukkit.getServer().getMap(id);
  if (mapView == null) {
    MiscUtil.log(Level.WARNING,"String_Node_Str" + id);
    return;
  }
  for (  MapRenderer r : mapView.getRenderers()) {
    previousRenderers.add(r);
    mapView.removeRenderer(r);
  }
  mapView.addRenderer(getMapRenderer());
  allMapViews.put(mapView.getId(),this);
  autosave();
}
Program: 19039
Project: 19039
Buggy source:
public String toString(){
  return "String_Node_Str" + mapView.getId();
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + (mapView == null ? "String_Node_Str" : mapView.getId());
}
Program: 19040
Project: 19040
Buggy source:
@Override public void deletePermanent(){
  allMapViews.remove(mapView.getId());
  mapView.removeRenderer(getMapRenderer());
  for (  MapRenderer r : previousRenderers) {
    mapView.addRenderer(r);
  }
  super.deletePermanent();
}

Fixed version (ground truth):
@Override public void deletePermanent(){
  if (mapView != null) {
    allMapViews.remove(mapView.getId());
    mapView.removeRenderer(getMapRenderer());
    for (    MapRenderer r : previousRenderers) {
      mapView.addRenderer(r);
    }
  }
  super.deletePermanent();
}
Program: 19041
Project: 19041
Buggy source:
public String toString(){
  return "String_Node_Str" + MiscUtil.formatLocation(getLocationsArray()[0]);
}

Fixed version (ground truth):
public String toString(){
  Location[] locs=getLocationsArray();
  return "String_Node_Str" + (locs.length == 0 ? "String_Node_Str" : MiscUtil.formatLocation(getLocationsArray()[0]));
}