Advertisement
tensador125

Random Craft System Interlude v2 update

Jun 20th, 2023
1,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.13 KB | Gaming | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P OrionRev28
  3. diff --git files/game/data/xml/RandomCraft.xml files/game/data/xml/RandomCraft.xml
  4. index c4972de..954838c 100644
  5. --- files/game/data/xml/RandomCraft.xml
  6. +++ files/game/data/xml/RandomCraft.xml
  7. @@ -1,27 +1,38 @@
  8.  <?xml version="1.0" encoding="UTF-8"?>
  9.      <rewards>
  10. -        <item id="6392" count="1" chance="10" />
  11. -        <item id="5714" count="1" chance="10" />
  12. -        <item id="5715" count="1" chance="10" />
  13. -        <item id="5720" count="1" chance="10" />
  14. -        <item id="5727" count="1" chance="10" />
  15. -        <item id="5709" count="1" chance="10" />
  16. -        <item id="5765" count="1" chance="10" />
  17. -        <item id="5768" count="1" chance="10" />
  18. -        <item id="5777" count="1" chance="10" />
  19. -        <item id="5778" count="1" chance="10" />
  20. -        <item id="5779" count="1" chance="10" />
  21. -        <item id="5780" count="1" chance="10" />
  22. -        <item id="5787" count="1" chance="10" />
  23. -        <item id="5788" count="1" chance="10" />
  24. -        <item id="5783" count="1" chance="10" />
  25. -        <item id="5784" count="1" chance="10" />
  26. -        <item id="5781" count="1" chance="10" />
  27. -        <item id="5644" count="1" chance="20" />
  28. -        <item id="5706" count="1" chance="20" />
  29. -        <item id="5704" count="1" chance="20" />
  30. -        <item id="6372" count="1" chance="25" />
  31. -        <item id="6377" count="1" chance="50" />
  32. -        <item id="6367" count="1" chance="40" />
  33. +        <item id="6392" count="1" chance="10" announce="false" />
  34. +        <item id="5714" count="1" chance="10" announce="false" />
  35. +        <item id="5715" count="1" chance="10" announce="false" />
  36. +        <item id="5720" count="1" chance="10" announce="false" />
  37. +        <item id="5727" count="1" chance="10" announce="false" />
  38. +        <item id="5709" count="1" chance="10" announce="false" />
  39. +        <item id="5765" count="1" chance="10" announce="false" />
  40. +        <item id="5768" count="1" chance="15" announce="false" />
  41. +        <item id="5777" count="1" chance="15" announce="false" />
  42. +        <item id="5778" count="1" chance="15" announce="false" />
  43. +        <item id="5779" count="1" chance="15" announce="false" />
  44. +        <item id="5780" count="1" chance="20" announce="false" />
  45. +        <item id="5787" count="1" chance="20" announce="false" />
  46. +        <item id="5788" count="1" chance="20" announce="false" />
  47. +        <item id="5783" count="1" chance="20" announce="false" />
  48. +        <item id="5784" count="1" chance="20" announce="false" />
  49. +        <item id="5781" count="1" chance="20" announce="false" />
  50. +        <item id="5644" count="1" chance="25" announce="false" />
  51. +        <item id="5706" count="1" chance="25" announce="false" />
  52. +        <item id="5704" count="1" chance="25" announce="false" />
  53. +        <item id="6372" count="1" chance="25" announce="false" />
  54. +        <item id="6377" count="1" chance="30" announce="false" />
  55. +        <item id="6367" count="1" chance="40" announce="false" />
  56. +        <item id="6611" count="1" chance="80" announce="true" />
  57. +        <item id="6612" count="1" chance="80" announce="true" />
  58. +        <item id="6613" count="1" chance="80" announce="true" />
  59. +        <item id="6614" count="1" chance="80" announce="true" />
  60. +        <item id="6615" count="1" chance="80" announce="true" />
  61. +        <item id="6616" count="1" chance="80" announce="true" />  
  62. +        <item id="6617" count="1" chance="80" announce="true" />
  63. +        <item id="6618" count="1" chance="80" announce="true" />  
  64. +        <item id="6619" count="1" chance="80" announce="true" />
  65. +        <item id="6620" count="1" chance="80" announce="true" />
  66. +        <item id="6621" count="1" chance="80" announce="true" />
  67.      </rewards>
  68.  
  69. diff --git src/Base/RandomCraftSystem/RandomCraftItem.java src/Base/RandomCraftSystem/RandomCraftItem.java
  70. index 3687699..c4af9d2 100644
  71. --- src/Base/RandomCraftSystem/RandomCraftItem.java
  72. +++ src/Base/RandomCraftSystem/RandomCraftItem.java
  73. @@ -12,12 +12,14 @@
  74.     private int id;
  75.     private int cantidad;
  76.     private double probabilidad;
  77. +   private boolean announce;
  78.    
  79. -   public RandomCraftItem(int id, int cantidad, double probabilidad)
  80. +   public RandomCraftItem(int id, int cantidad, double probabilidad, boolean announce)
  81.     {
  82.         this.id = id;
  83.         this.cantidad = cantidad;
  84.         this.probabilidad = probabilidad;
  85. +       this.announce = announce;
  86.     }
  87.    
  88.     public int getId()
  89. @@ -35,6 +37,11 @@
  90.         return probabilidad;
  91.     }
  92.    
  93. +   public boolean getAnnounce()
  94. +   {
  95. +       return announce;
  96. +   }
  97. +  
  98.     public String getIcon()
  99.     {
  100.         return getItem().getIcon();
  101. @@ -44,5 +51,4 @@
  102.     {
  103.         return ItemTable.getInstance().getTemplate(id);
  104.     }
  105. -  
  106.  }
  107. diff --git src/Base/RandomCraftSystem/RandomCraftXML.java src/Base/RandomCraftSystem/RandomCraftXML.java
  108. index 242304e..46e14dd 100644
  109. --- src/Base/RandomCraftSystem/RandomCraftXML.java
  110. +++ src/Base/RandomCraftSystem/RandomCraftXML.java
  111. @@ -59,8 +59,9 @@
  112.                 int id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
  113.                 int cantidad = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
  114.                 double probabilidad = Double.parseDouble(attrs.getNamedItem("chance").getNodeValue());
  115. +               boolean announce = Boolean.parseBoolean(attrs.getNamedItem("announce").getNodeValue());
  116.                
  117. -               RandomCraftItem item = new RandomCraftItem(id, cantidad, probabilidad);
  118. +               RandomCraftItem item = new RandomCraftItem(id, cantidad, probabilidad, announce);
  119.                 items.put(id, item);
  120.             }
  121.         }
  122. diff --git src/l2jorion/game/model/actor/instance/L2RandomCraftInstance.java src/l2jorion/game/model/actor/instance/L2RandomCraftInstance.java
  123. index a528388..045ed2e 100644
  124. --- src/l2jorion/game/model/actor/instance/L2RandomCraftInstance.java
  125. +++ src/l2jorion/game/model/actor/instance/L2RandomCraftInstance.java
  126. @@ -14,7 +14,9 @@
  127.  import Base.RandomCraftSystem.RandomCraftXML;
  128.  import l2jorion.Config;
  129.  import l2jorion.game.ai.CtrlIntention;
  130. +import l2jorion.game.model.L2World;
  131.  import l2jorion.game.network.serverpackets.ActionFailed;
  132. +import l2jorion.game.network.serverpackets.ExShowScreenMessage;
  133.  import l2jorion.game.network.serverpackets.ItemList;
  134.  import l2jorion.game.network.serverpackets.MoveToPawn;
  135.  import l2jorion.game.network.serverpackets.MyTargetSelected;
  136. @@ -187,7 +189,7 @@
  137.             stmt.execute();
  138.             stmt.close();
  139.            
  140. -           stmt = con.prepareStatement("INSERT INTO RandomCraftItem (object_id, item_id, amount, chance) VALUES (?, ?, ?, ?)");
  141. +           stmt = con.prepareStatement("INSERT INTO RandomCraftItem (object_id, item_id, amount, chance, announce) VALUES (?, ?, ?, ?, ?)");
  142.             stmt.setInt(1, player.getObjectId());
  143.             List<RandomCraftItem> items = player.getGeneratedCraftItems();
  144.             if (items != null)
  145. @@ -197,6 +199,7 @@
  146.                     stmt.setInt(2, item.getId());
  147.                     stmt.setInt(3, item.getCantidad());
  148.                     stmt.setDouble(4, item.getProbabilidad());
  149. +                   stmt.setBoolean(5, item.getAnnounce());
  150.                     stmt.addBatch(); // Agregar la consulta al lote (batch)
  151.                 }
  152.                 stmt.executeBatch(); // Ejecutar el lote de consultas
  153. @@ -244,7 +247,7 @@
  154.         try
  155.         {
  156.             con = L2DatabaseFactory.getInstance().getConnection();
  157. -           stmt = con.prepareStatement("SELECT item_id, amount, chance FROM RandomCraftItem WHERE object_id = ?");
  158. +           stmt = con.prepareStatement("SELECT item_id, amount, chance, announce FROM RandomCraftItem WHERE object_id = ?");
  159.             stmt.setInt(1, player.getObjectId());
  160.             rset = stmt.executeQuery();
  161.            
  162. @@ -254,7 +257,8 @@
  163.                 int itemId = rset.getInt("item_id");
  164.                 int amount = rset.getInt("amount");
  165.                 int chance = rset.getInt("chance");
  166. -               RandomCraftItem item = new RandomCraftItem(itemId, amount, chance);
  167. +               boolean announce = rset.getBoolean("announce");
  168. +               RandomCraftItem item = new RandomCraftItem(itemId, amount, chance, announce);
  169.                 items.add(item);
  170.             }
  171.            
  172. @@ -326,7 +330,7 @@
  173.    
  174.     private void createItem(L2PcInstance player)
  175.     {
  176. -       // Compruebe si la lista de elementos está vacía
  177. +       // Comprueba si la lista de elementos está vacía
  178.         List<RandomCraftItem> items = player.getGeneratedCraftItems();
  179.         if (items == null || items.isEmpty())
  180.         {
  181. @@ -334,18 +338,18 @@
  182.             return;
  183.         }
  184.        
  185. -       // Obtenga un elemento aleatorio de la lista de elementos generados
  186. +       // Obtén un elemento aleatorio de la lista de elementos generados
  187.         Random random = new Random();
  188.         int index = random.nextInt(items.size());
  189.         RandomCraftItem craftItem = items.get(index);
  190.        
  191. -       // Cargue al jugador el artículo con ID 57 y cantidad 300000
  192. +       // Carga al jugador el artículo con ID 57 y cantidad 300000
  193.         L2ItemInstance item57 = player.getInventory().getItemByItemId(Config.RANDOM_CRAFT_ITEM_ID_CONSUME);
  194.         if (item57 != null && item57.getCount() >= Config.RANDOM_CRAFT_ITEM_CONSUME_CREATE)
  195.         {
  196.             player.getInventory().destroyItemByItemId("Random Craft", Config.RANDOM_CRAFT_ITEM_ID_CONSUME, Config.RANDOM_CRAFT_ITEM_CONSUME_CREATE, player, this);
  197.            
  198. -           // Dar el artículo al jugado
  199. +           // Da el artículo al jugador
  200.             L2ItemInstance itemInstance = player.getInventory().addItem("Random Craft", craftItem.getId(), craftItem.getCantidad(), player, this);
  201.             if (itemInstance != null)
  202.             {
  203. @@ -355,7 +359,25 @@
  204.                 String message = "¡Felicidades! Has recibido " + craftItem.getItem().getName() + " (Cantidad: " + craftItem.getCantidad() + ")";
  205.                 player.sendMessage(message);
  206.                
  207. -               // Borrar la lista de elementos para el jugador
  208. +               // Obtén el nombre del jugador que creó el elemento
  209. +               String creatorName = player.getName();
  210. +              
  211. +               // Comprueba si el artículo tiene announce en true en el archivo XML
  212. +               if (craftItem.getAnnounce())
  213. +               {
  214. +                  
  215. +                   for (L2PcInstance players : L2World.getInstance().getAllPlayers().values())
  216. +                   {
  217. +                      
  218. +                       String text = creatorName + " Ha Crafteado: " + craftItem.getItem().getName() + " En el RandomCraft System";
  219. +                      
  220. +                       players.sendPacket(new ExShowScreenMessage(text, 12000, 2, true));
  221. +                      
  222. +                   }
  223. +                  
  224. +               }
  225. +              
  226. +               // Borra la lista de elementos para el jugador
  227.                 player.clearGeneratedCraftItems();
  228.                 setHasGeneratedItems(false);
  229.                 return;
  230.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement