RuneHive-Game
Loading...
Searching...
No Matches
ItemDBdefUpdate.java
Go to the documentation of this file.
1package com.runehive.util.tools;
2
3import com.jcabi.jdbc.JdbcSession;
4import com.runehive.game.service.PostgreService;
5import com.runehive.game.world.items.ItemDefinition;
6
7public class ItemDBdefUpdate {
8
9 public static void main(String[] args) {
10 String query = "INSERT INTO lookup.item_lookup(id, name, value) VALUES (?, ?, ?) ON CONFLICT (id) DO UPDATE SET id = excluded.id, name = excluded.name, value = excluded.value";
11
13
14 try {
15 JdbcSession session = new JdbcSession(PostgreService.getConnectionPool()).autocommit(false);
16 System.out.println("Starting");
17
18 for (int index = 21708; index < ItemDefinition.DEFINITIONS.length; index++) {
19 ItemDefinition definition = ItemDefinition.get(index);
20
21 if (definition.getName() != null && !definition.getName().equals("null")) {
22 continue;
23 }
24
25 session
26 .sql(query)
27 .set(definition.getId())
28 .set(definition.getName())
29 .set(definition.getValue())
30 .execute();
31 }
32
33 session.commit();
34 System.out.println("Success");
35 } catch (Exception e) {
36 e.printStackTrace();
37 }
38 }
39
40}
static HikariDataSource getConnectionPool()
Represents all of an in-game Item's attributes.
static ItemDefinition get(int id)
Gets an item definition.
static ItemDefinition[] DEFINITIONS
An array of item definitions.