Here you can find the source of replaceNpcId(final List
Parameter | Description |
---|---|
npcListSqlLines | Line Array of the NPC List SQL |
lineIndex | Index of Current Line |
newNpcId | New Short NPC ID |
public static void replaceNpcId(final List<String> npcListSqlLines, final int lineIndex, final int newNpcId, final boolean markAsGuess)
//package com.java2s; /** //www . j av a 2 s. com * Copyright (c) 2010-2014 Darkstar Dev Teams * * 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 3 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/ * * This file is part of DarkStar-server source code. */ import java.util.List; public class Main { public static final String NPC_LIST_INSERT_START = "INSERT INTO `npc_list` VALUES ("; /** * Method to Replace the NPC ID on the Current Line w/ a New One * @param npcListSqlLines Line Array of the NPC List SQL * @param lineIndex Index of Current Line * @param newNpcId New Short NPC ID */ public static void replaceNpcId(final List<String> npcListSqlLines, final int lineIndex, final int newNpcId, final boolean markAsGuess) { final String npcIdLine = npcListSqlLines.get(lineIndex); final int endIndex = npcIdLine.indexOf(","); final String insertStringFragment = npcIdLine.substring(0, NPC_LIST_INSERT_START.length()); final String postIdFragment = npcIdLine.substring(endIndex, npcIdLine.length()); String newNpcIdLine = insertStringFragment + newNpcId + postIdFragment; if (markAsGuess) { newNpcIdLine = "FIXME: " + newNpcIdLine; } npcListSqlLines.set(lineIndex, newNpcIdLine); } }