Rename and clean up MapleShopFactory
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
const MapleShopFactory = Java.type('server.MapleShopFactory');
|
const ShopFactory = Java.type('server.ShopFactory');
|
||||||
MapleShopFactory.getInstance().getShop(11000).sendShop(cm.getClient());
|
ShopFactory.getInstance().getShop(11000).sendShop(cm.getClient());
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package client.command.commands.gm2;
|
|||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import server.MapleShopFactory;
|
import server.ShopFactory;
|
||||||
|
|
||||||
public class GmShopCommand extends Command {
|
public class GmShopCommand extends Command {
|
||||||
{
|
{
|
||||||
@@ -34,6 +34,6 @@ public class GmShopCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Client c, String[] params) {
|
public void execute(Client c, String[] params) {
|
||||||
MapleShopFactory.getInstance().getShop(1337).sendShop(c);
|
ShopFactory.getInstance().getShop(1337).sendShop(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package client.command.commands.gm3;
|
|||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.command.Command;
|
import client.command.Command;
|
||||||
import server.MapleShopFactory;
|
import server.ShopFactory;
|
||||||
|
|
||||||
|
|
||||||
public class ReloadShopsCommand extends Command {
|
public class ReloadShopsCommand extends Command {
|
||||||
@@ -35,6 +35,6 @@ public class ReloadShopsCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Client c, String[] params) {
|
public void execute(Client c, String[] params) {
|
||||||
MapleShopFactory.getInstance().reloadShops();
|
ShopFactory.getInstance().reloadShops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ import net.AbstractPacketHandler;
|
|||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
import server.ItemInformationProvider;
|
import server.ItemInformationProvider;
|
||||||
import server.MapleShopFactory;
|
|
||||||
import server.Shop;
|
import server.Shop;
|
||||||
|
import server.ShopFactory;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
import server.maps.*;
|
import server.maps.*;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
@@ -494,7 +494,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
} else if (itemType == 545) { // MiuMiu's travel store
|
} else if (itemType == 545) { // MiuMiu's travel store
|
||||||
if (player.getShop() == null) {
|
if (player.getShop() == null) {
|
||||||
Shop shop = MapleShopFactory.getInstance().getShop(1338);
|
Shop shop = ShopFactory.getInstance().getShop(1338);
|
||||||
if (shop != null) {
|
if (shop != null) {
|
||||||
shop.sendShop(c);
|
shop.sendShop(c);
|
||||||
remove(c, position, itemId);
|
remove(c, position, itemId);
|
||||||
|
|||||||
@@ -373,13 +373,13 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void openShopNPC(int id) {
|
public void openShopNPC(int id) {
|
||||||
Shop shop = MapleShopFactory.getInstance().getShop(id);
|
Shop shop = ShopFactory.getInstance().getShop(id);
|
||||||
|
|
||||||
if (shop != null) {
|
if (shop != null) {
|
||||||
shop.sendShop(c);
|
shop.sendShop(c);
|
||||||
} else { // check for missing shopids thanks to resinate
|
} else { // check for missing shopids thanks to resinate
|
||||||
FilePrinter.printError(FilePrinter.NPC_UNCODED, "Shop ID: " + id + " is missing from database.");
|
FilePrinter.printError(FilePrinter.NPC_UNCODED, "Shop ID: " + id + " is missing from database.");
|
||||||
MapleShopFactory.getInstance().getShop(11000).sendShop(c);
|
ShopFactory.getInstance().getShop(11000).sendShop(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,19 +25,17 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
*/
|
*/
|
||||||
public class MapleShopFactory {
|
public class ShopFactory {
|
||||||
|
private static final ShopFactory instance = new ShopFactory();
|
||||||
private static MapleShopFactory instance = new MapleShopFactory();
|
|
||||||
|
public static ShopFactory getInstance() {
|
||||||
public static MapleShopFactory getInstance() {
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer, Shop> shops = new HashMap<>();
|
private final Map<Integer, Shop> shops = new HashMap<>();
|
||||||
private Map<Integer, Shop> npcShops = new HashMap<>();
|
private final Map<Integer, Shop> npcShops = new HashMap<>();
|
||||||
|
|
||||||
private Shop loadShop(int id, boolean isShopId) {
|
private Shop loadShop(int id, boolean isShopId) {
|
||||||
Shop ret = Shop.createFromDB(id, isShopId);
|
Shop ret = Shop.createFromDB(id, isShopId);
|
||||||
@@ -65,7 +63,7 @@ public class MapleShopFactory {
|
|||||||
}
|
}
|
||||||
return loadShop(npcId, false);
|
return loadShop(npcId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadShops() {
|
public void reloadShops() {
|
||||||
shops.clear();
|
shops.clear();
|
||||||
npcShops.clear();
|
npcShops.clear();
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
package server.life;
|
package server.life;
|
||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import server.MapleShopFactory;
|
import server.ShopFactory;
|
||||||
import server.maps.MapObjectType;
|
import server.maps.MapObjectType;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
@@ -35,11 +35,11 @@ public class NPC extends AbstractLoadedLife {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasShop() {
|
public boolean hasShop() {
|
||||||
return MapleShopFactory.getInstance().getShopForNPC(getId()) != null;
|
return ShopFactory.getInstance().getShopForNPC(getId()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendShop(Client c) {
|
public void sendShop(Client c) {
|
||||||
MapleShopFactory.getInstance().getShopForNPC(getId()).sendShop(c);
|
ShopFactory.getInstance().getShopForNPC(getId()).sendShop(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user