· 6 years ago · Nov 28, 2019, 03:38 AM
1MapleMapFactory.java
2
3
4 public void getFixNpc(MapleMap map, int mapid) {
5 Connection con = null;
6 PreparedStatement ps = null;
7 ResultSet rs = null;
8 try {
9 con = DatabaseConnection.getConnection();
10 ps = con.prepareStatement("SELECT * FROM spawnnpc WHERE mapid = ?");
11 ps.setInt(1, mapid);
12 rs = ps.executeQuery();
13
14 while (rs.next()) {
15 MapleNPC npc = MapleLifeFactory.getNPC(rs.getInt("npcid"));
16 npc.setCy(rs.getInt("cy"));
17 npc.setRx0(rs.getInt("rx0"));
18 npc.setRx1(rs.getInt("rx1"));
19 npc.setFh(rs.getInt("fh"));
20 npc.setPosition(new Point(npc.getRx0() + 50, npc.getCy()));
21 map.addMapObject(npc);
22 }
23
24 rs.close();
25 ps.close();
26 con.close();
27 } catch(SQLException ex) {
28 System.out.println("fix npc error ");
29 ex.printStackTrace();
30 } finally {
31 if (con != null) {
32 try {
33 con.close();
34 } catch (SQLException ex) {
35 }
36 }
37
38 if (ps != null) {
39 try {
40 ps.close();
41 } catch (SQLException ex) {
42 }
43 }
44
45 if (rs != null) {
46 try {
47 rs.close();
48 } catch (SQLException ex) {
49 }
50 }
51 }
52 }
53
54-----
55
56public final MapleMap getMap(final int mapid, final boolean respawns, final boolean npcs, final boolean reactors) {
57찾아 try문 밑에
58
59getFixNpc(map, mapid);
60
61----
62
63그리고 커맨드 추가
64
65 public static class 고정엔피시 extends CommandExecute {
66 @Override
67 public int execute(MapleClient c, String[] splitted) {
68 int npcId = Integer.parseInt(splitted[1]);
69 MapleNPC npc = MapleLifeFactory.getNPC(npcId);
70 if (npc != null && !npc.getName().equals("MISSINGNO")) {
71 npc.setPosition(c.getPlayer().getPosition());
72 npc.setCy(c.getPlayer().getPosition().y);
73 npc.setRx0(c.getPlayer().getPosition().x + 50);
74 npc.setRx1(c.getPlayer().getPosition().x - 50);
75 npc.setFh(c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
76 c.getPlayer().getMap().addMapObject(npc);
77 c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc, true));
78 } else {
79 c.getPlayer().dropMessage(6, "WZ에 존재하지 않는 NPC를 입력했습니다.");
80 return 0;
81 }
82 try {
83 String sql = "INSERT INTO spawnnpc(npcid, rx0, rx1, cy, fh, mapid) VALUES (? ,? ,? ,? ,? ,?)";
84 PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement(sql);
85 ps.setInt(1, npcId);
86 ps.setInt(2, c.getPlayer().getPosition().x - 50);
87 ps.setInt(3, c.getPlayer().getPosition().x + 50);
88 ps.setInt(4, c.getPlayer().getPosition().y);
89 ps.setInt(5, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
90 ps.setInt(6, c.getPlayer().getMapId());
91 ps.executeUpdate();
92 ps.close();
93 } catch (Exception e) {
94 System.err.println("fix npc error.");
95 e.printStackTrace();
96 }
97 return 1;
98 }
99 }
100
101
102
103
104-- MySQL Administrator dump 1.4
105--
106-- ------------------------------------------------------
107-- Server version 6.0.0-alpha-community-nt-debug
108
109
110/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
111/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
112/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
113/*!40101 SET NAMES utf8 */;
114
115/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
116/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
117/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
118
119
120--
121-- Create schema maplestory
122--
123
124CREATE DATABASE IF NOT EXISTS maplestory;
125USE maplestory;
126
127--
128-- Definition of table `spawnnpc`
129--
130
131DROP TABLE IF EXISTS `spawnnpc`;
132CREATE TABLE `spawnnpc` (
133 `npcid` int(11) NOT NULL AUTO_INCREMENT,
134 `rx0` int(11) NOT NULL,
135 `rx1` int(11) NOT NULL,
136 `cy` int(11) NOT NULL,
137 `fh` int(11) NOT NULL,
138 `mapid` int(11) NOT NULL,
139 PRIMARY KEY (`npcid`)
140) ENGINE=InnoDB DEFAULT CHARSET=latin1;
141
142/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
143/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
144/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
145/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
146/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
147/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
148/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;