Autor Tema: Class Id name  (Leído 206 veces)

Mordor

  • Jr. Member
  • **
  • Mensajes: 83
  • Karma: +0/-0
    • Ver Perfil
Class Id name
« en: Enero 22, 2018, 09:06:05 pm »
Buenas, he modificado el class name para "mejorarlo", me quedo asi:

https://ibb.co/fPnZrw

Ruta:
net.sf.l2j.gameserver.datatables.CharTemplateTable

Código
/*
 * Copyright (C) 2014-2020 L2jAdjmins
 *
 * This file is part of L2jAdmins.
 *
 * L2jAdmins 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.
 *
 * L2jAdmins 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/>.
 */
package net.sf.l2j.gameserver.datatables;

import java.util.HashMap;
import java.util.Map;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import net.sf.l2j.gameserver.model.StatsSet;
import net.sf.l2j.gameserver.model.actor.base.ClassId;
import net.sf.l2j.gameserver.model.actor.templates.PcTemplate;
import net.sf.l2j.util.XmlParser;

/**
 * @author fissban
 */
public class CharTemplateTable extends XmlParser
{
private static final Map<Integer, PcTemplate> _charTemplates = new HashMap<>();

private static final String[] CHAR_CLASSES =
{
"Human Fighter",
"Warrior",
"Gladiator",
"Warlord",
"Human Knight",
"Paladin",
"Dark Avenger",
"Rogue",
"Treasure Hunter",
"Hawkeye",
"Human Mystic",
"Human Wizard",
"Sorceror",
"Necromancer",
"Warlock",
"Cleric",
"Bishop",
"Prophet",
"Elven Fighter",
"Elven Knight",
"Temple Knight",
"Swordsinger",
"Elven Scout",
"Plainswalker",
"Silver Ranger",
"Elven Mystic",
"Elven Wizard",
"Spellsinger",
"Elemental Summoner",
"Elven Oracle",
"Elven Elder",
"Dark Fighter",
"Palus Knight",
"Shillien Knight",
"Bladedancer",
"Assassin",
"Abyss Walker",
"Phantom Ranger",
"Dark Elven Mystic",
"Dark Elven Wizard",
"Spellhowler",
"Phantom Summoner",
"Shillien Oracle",
"Shillien Elder",
"Orc Fighter",
"Orc Raider",
"Destroyer",
"Orc Monk",
"Tyrant",
"Orc Mystic",
"Orc Shaman",
"Overlord",
"Warcryer",
"Dwarven Fighter",
"Dwarven Scavenger",
"Bounty Hunter",
"Dwarven Artisan",
"Warsmith",
"dummyEntry1",
"dummyEntry2",
"dummyEntry3",
"dummyEntry4",
"dummyEntry5",
"dummyEntry6",
"dummyEntry7",
"dummyEntry8",
"dummyEntry9",
"dummyEntry10",
"dummyEntry11",
"dummyEntry12",
"dummyEntry13",
"dummyEntry14",
"dummyEntry15",
"dummyEntry16",
"dummyEntry17",
"dummyEntry18",
"dummyEntry19",
"dummyEntry20",
"dummyEntry21",
"dummyEntry22",
"dummyEntry23",
"dummyEntry24",
"dummyEntry25",
"dummyEntry26",
"dummyEntry27",
"dummyEntry28",
"dummyEntry29",
"dummyEntry30",
"Duelist",
"DreadNought",
"Phoenix Knight",
"Hell Knight",
"Sagittarius",
"Adventurer",
"Archmage",
"Soultaker",
"Arcana Lord",
"Cardinal",
"Hierophant",
"Eva Templar",
"Sword Muse",
"Wind Rider",
"Moonlight Sentinel",
"Mystic Muse",
"Elemental Master",
"Eva's Saint",
"Shillien Templar",
"Spectral Dancer",
"Ghost Hunter",
"Ghost Sentinel",
"Storm Screamer",
"Spectral Master",
"Shillien Saint",
"Titan",
"Grand Khauatari",
"Dominator",
"Doomcryer",
"Fortune Seeker",
"Maestro"
};

@Override
public void load()
{
parseDatapackFile("data/xml/stats/charTemplates.xml");
LOG.info(getClass().getSimpleName() + ": Loaded: " + _charTemplates.size() + " char templates.");
}

@Override
protected void parseDocument()
{
for (Node d = getCurrentDocument().getFirstChild().getFirstChild(); d != null; d = d.getNextSibling())
{
if (d.getNodeName().equals("class"))
{
NamedNodeMap attrs = d.getAttributes();

StatsSet set = new StatsSet();
set.set("id", attrs.getNamedItem("id").getNodeValue());
set.set("name", attrs.getNamedItem("name").getNodeValue());
set.set("race", attrs.getNamedItem("race").getNodeValue());

for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if (c.getNodeName().equals("set"))
{
attrs = c.getAttributes();
String name = attrs.getNamedItem("name").getNodeValue();
String value = attrs.getNamedItem("val").getNodeValue();
set.set(name, value);
}
}

_charTemplates.put(set.getInteger("id", 0), new PcTemplate(set));
}
}
}

public PcTemplate getTemplate(ClassId classId)
{
return getTemplate(classId.getId());
}

public PcTemplate getTemplate(int classId)
{
return _charTemplates.get(classId);
}

public final static String getClassNameById(int classId)
{
return CHAR_CLASSES[classId];
}

public static CharTemplateTable getInstance()
{
return SingletonHolder._instance;
}

private static class SingletonHolder
{
protected static final CharTemplateTable _instance = new CharTemplateTable();
}
}
« Última modificación: Enero 24, 2018, 09:03:05 pm por fissban »

fissban

  • Administrador
  • Full Member
  • *
  • Mensajes: 123
  • Karma: +0/-0
    • Ver Perfil
Re:Class Id name
« Respuesta #1 en: Enero 22, 2018, 09:58:23 pm »
mejor proba este codigo haber como queda

Código
### Eclipse Workspace Patch 1.0
#P C4_DataPack
Index: data/scripts/events/classmaster/ClassMaster.java
===================================================================
--- data/scripts/events/classmaster/ClassMaster.java (revision 911)
+++ data/scripts/events/classmaster/ClassMaster.java (working copy)
@@ -174,7 +174,7 @@
  if (validateClassId(currentClassId, cid) && (cid.level() == level))
  {
  menu.append("<button value=\"");
- menu.append(CharTemplateTable.getClassNameById(cid.getId()) + "\" ");
+ menu.append(cid.getName() + "\" ");
  menu.append("action=\"bypass -h Quest ClassMaster change_class ");
  menu.append(String.valueOf(cid.getId()) + "\"");
  menu.append(" width=204 height=20 back=\"sek.cbui77\" fore=\"sek.cbui75\"><br>");
@@ -184,7 +184,7 @@
  if (menu.length() > 0)
  {
  html.setFile(HTML_PATH + "template.htm");
- html.replace("%name%", CharTemplateTable.getClassNameById(currentClassId.getId()));
+ html.replace("%name%", currentClassId.name());
  html.replace("%menu%", menu.toString());
  }
  else
#P C4_GameServer
Index: java/net/sf/l2j/gameserver/model/actor/base/ClassId.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/base/ClassId.java (revision 911)
+++ java/net/sf/l2j/gameserver/model/actor/base/ClassId.java (working copy)
@@ -169,7 +169,28 @@
 
  public String getName()
  {
- return toString().replace("_", " ").toLowerCase();
+ String name = toString().toLowerCase();
+
+ boolean upperCase = true;
+ for (char c : name.toLowerCase().toCharArray())
+ {
+ if (String.valueOf(c).equals("_"))
+ {
+ name += " ";
+ upperCase = true;
+ }
+ else if (upperCase)
+ {
+ name += String.valueOf(c).toUpperCase();
+ upperCase = false;
+ }
+ else
+ {
+ name += c;
+ }
+ }
+
+ return name;
  }
 
  /**

por cierto....buena observacion

Mordor

  • Jr. Member
  • **
  • Mensajes: 83
  • Karma: +0/-0
    • Ver Perfil
Re:Class Id name
« Respuesta #2 en: Enero 22, 2018, 10:16:33 pm »
Puse la tabla CharTemplateTable como esta en el svn actual, pegue el fix pero me sale esto:
https://ibb.co/cCBxdb


fissban

  • Administrador
  • Full Member
  • *
  • Mensajes: 123
  • Karma: +0/-0
    • Ver Perfil
Re:Class Id name
« Respuesta #3 en: Enero 22, 2018, 11:45:12 pm »