Quantcast
Channel: RaGEZONE - MMO Development Forums
Viewing all articles
Browse latest Browse all 14581

[Release] [116] Ciphra/Lithium Block/Edit Cash item with out WZ edit

$
0
0
Hi.
I've played in Extalia and see they block items from the CS without editing WZ. And after a dozen times tried & failed. I have figured out how it work.

Here is my CasItemFactory.java.
Spoiler:

PHP Code:

/*
 This file is part of the OdinMS Maple Story Server
 Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc> 
 Matthias Butz <matze@odinms.de>
 Jan Christian Meyer <vimes@odinms.de>

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License version 3
 as published by the Free Software Foundation. You may not use, modify
 or distribute this program under any other version of the
 GNU Affero General Public License.

 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package server;

import database.DatabaseConnection;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import provider.MapleData;
import provider.MapleDataProvider;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
import server.CashItemInfo.CashModInfo;

public class 
CashItemFactory {

    private final static 
CashItemFactory instance = new CashItemFactory();
    private final static 
int[] bestItems = new int[]{54500001012126523000055100005520000};
    private final 
Map<IntegerCashItemInfoitemStats = new HashMap<>();
    private final 
Map<Integer, List<Integer>> itemPackage = new HashMap<>();
    private final 
Map<IntegerCashModInfoitemMods = new HashMap<>();
    private final 
Map<Integer, List<Integer>> openBox = new HashMap<>();
    private final 
MapleDataProvider data MapleDataProviderFactory.getDataProvider(new File("Wz/Etc.wz"));
    private static List<
Integerblacklist = new ArrayList<>(); 

    public static 
CashItemFactory getInstance() {
        return 
instance;
    }

    public final 
void initialize() {
        try {
            
itemMods.clear();
            
itemStats.clear();
            
itemPackage.clear();
            
openBox.clear();
            try {
                
BufferedReader reader = new BufferedReader(new FileReader("CBlackList.ini"));
                
String line reader.readLine();
                while (
line != null) {
                    try {
                        if (!
line.isEmpty() && !line.split(",")[0].startsWith("#")) {
                            
getBlacklist().add(Integer.parseInt(line.split(",")[0]));
                        }
                    } catch (
Exception ex) {
//                        System.err.println("Error while loading Black listed Cash Item.\r\n" + ex.getMessage());
                    
}
                    
line reader.readLine();
                }
            } catch (
IOException NumberFormatException ex) {
                
System.err.println("Error while loading cash black list.\r\n" ex.getMessage());
            }
            
Connection con DatabaseConnection.getConnection();
            
PreparedStatement ps con.prepareStatement("SELECT * FROM cashshop_modified_items");
            
ResultSet rs ps.executeQuery();
            while (
rs.next()) {
                
CashModInfo modded = new CashModInfo(rs.getInt("serial"), rs.getInt("discount_price"), 
                        
rs.getInt("mark"), rs.getInt("showup") > 0rs.getInt("itemid"), 
                        
rs.getInt("priority"), rs.getInt("package") > 0rs.getInt("period"), 
                        
rs.getInt("gender"), rs.getInt("count"), rs.getInt("meso"), rs.getInt("unk_1"), 
                        
rs.getInt("unk_2"), rs.getInt("unk_3"), rs.getInt("extra_flags"));
                
itemMods.put(modded.snmodded);
                if (
modded.showUp) {
                    final 
CashItemInfo cc itemStats.get(Integer.valueOf(modded.sn));
                    if (
cc != null) {
                        
modded.toCItem(cc); //init
                    
}
                }
            }
            
rs.close();
            
ps.close();
            
con.close();
            final List<
MapleDatacccc data.getData("Commodity.img").getChildren();
            for (
MapleData field cccc) {
                final 
int SN MapleDataTool.getIntConvert("SN"field0);
                
int ID MapleDataTool.getIntConvert("ItemId"field0);
                final 
int Bonus MapleDataTool.getIntConvert("Bonus"field0);
                final 
int Period MapleDataTool.getIntConvert("Period"field0);
                final 
int Priority MapleDataTool.getIntConvert("Priority"field0);
                final 
int Count MapleDataTool.getIntConvert("Count"field1);
                final 
int Price MapleDataTool.getIntConvert("Price"field0);
                final 
int Gender MapleDataTool.getIntConvert("Gender"field2);
                final 
boolean OnSale MapleDataTool.getIntConvert("OnSale"field0) > && Price 0;

                if (
getBlacklist().contains(ID) || ((Period == && OnSale))) { // Block black listed item from CS
                    
if (!itemMods.containsKey(SN)) {
                        
itemMods.put(SN, new CashModInfo(SN0, -1falseID100false0Gender0000040000));
                    }
                }

                final 
CashItemInfo stats = new CashItemInfo(IDCountPriceSNPeriodGenderOnSale);

                if (
SN 0) {
                    
itemStats.put(SNstats);
                }
            }

            final 
MapleData b data.getData("CashPackage.img");
            for (
MapleData c b.getChildren()) {
                if (
c.getChildByPath("SN") == null) {
                    continue;
                }
                final 
int packageID Integer.parseInt(c.getName());
                final List<
IntegerpackageItems = new ArrayList<>();
                for (
MapleData d c.getChildByPath("SN").getChildren()) {
                    
packageItems.add(MapleDataTool.getIntConvert(d));
                }
                for (
int pi packageItems) { // Block Cash Package if contain item in black list
                    
if (getBlacklist().contains((itemStats.containsKey(pi) ? itemStats.get(pi).getId() : 0))) {
                        for (
int _SN getSN(packageID)) {
                            if (!
itemMods.containsKey(_SN)) {
                                
itemMods.put(_SN, new CashModInfo(_SN0, -1false0100false020000040000));
                            }
                        }
                    }
                }
                
itemPackage.put(packageIDpackageItems);
            }

            for (
int i 0getBlacklist().size(); i++) { // Block Cash Packages
                
if (getBlacklist().get(i) / 100000 == 9) { // Package only
                    
for (int _SN getSN(getBlacklist().get(i))) {
                        if (!
itemMods.containsKey(_SN)) {
                            
itemMods.put(_SN, new CashModInfo(_SN0, -1false0100false020000040000));
                        }
                    }
                }
            }
        } catch (
SQLException NumberFormatException e) {
            
System.err.println("[Error] An error has occured during init CashItemFactory.\r\n" e.getMessage());
        }
    }

    private List<
IntegergetSN(int ItemId) {
        final List<
IntegerSN = new ArrayList<>();
        for (
Entry<IntegerCashItemInfoitem itemStats.entrySet()) {
            if (
ItemId == item.getValue().getId()) {
                
SN.add(item.getKey());
            }
        }
        return 
SN;
    }

    public final 
CashItemInfo getSimpleItem(int sn) {
        return 
itemStats.get(sn);
    }

    public final 
CashItemInfo getItem(int sn) {
        final 
CashItemInfo stats itemStats.get(Integer.valueOf(sn));
        final 
CashModInfo z getModInfo(sn);
        if (
!= null && z.showUp) {
            return 
z.toCItem(stats); //null doesnt matter
        
}
        if (
stats == null || !stats.onSale()) {
            return 
null;
        }
        
//hmm
        
return stats;
    }

    public final List<
IntegergetPackageItems(int packageID) {
        return 
itemPackage.get(packageID);
    }

    public final 
CashModInfo getModInfo(int sn) {
        return 
itemMods.get(sn);
    }

    public final 
Collection<CashModInfogetAllModInfo() {
        return 
itemMods.values();
    }

    public final 
Map<Integer, List<Integer>> getRandomItemInfo() {
        return 
openBox;
    }

    public final 
int[] getBestItems() {
        return 
bestItems;
    }

    public static List<
IntegergetBlacklist() {
        return 
blacklist;
    }

    public static 
void setBlacklist(List<IntegeraBlacklist) {
        
blacklist aBlacklist;
    }




And you can see. I load a list of items from the database. This is the information about the items that I want to change in CS. You can change everything like price, period, priority, ...

cashshop_modified_items
Spoiler:

PHP Code:

INSERT  INTO `cashshop_modified_items` (`serial`, `discount_price`, `mark`, `showup`, `itemid`, `priority`, `period`, `gender`, `count`,  `package`) VALUES (100118608900'0''1'18020381630210); -- Mini Celestial Wand OSN10002987 NSN10011860

INSERT  INTO 
`cashshop_modified_items` (`serial`, `discount_price`, `mark`, `showup`, `itemid`, `priority`, `period`, `gender`, `count`,  `package`) VALUES (100180101200'0''1'18120002530210); -- Meso Magnet OSN10003095 NSN10018010

INSERT  INTO 
`cashshop_modified_items` (`serial`, `discount_price`, `mark`, `showup`, `itemid`, `priority`, `period`, `gender`, `count`,  `package`) VALUES (101009781200'0''1'18120012530210); -- Item Pouch OSN10003096 NSN10100978 



CBlackList.ini
Spoiler:

PHP Code:

5750000// Alien Cube
5062000// Miracle Cube
5062001// Premium Miracle Cube
5062002// Super Miracle Cube
5062003// Revolutionary Miracle Cube
5062005// Enlightening Miracle Cube
5062100// 8th Anniversary Miracle Cube 


Viewing all articles
Browse latest Browse all 14581

Trending Articles