/** * Called on instance finish and handles reenter time for instance * * @param world instanceWorld */ private static final void finishInstance(InstanceWorld world) { if (world instanceof KamaWorld) { Calendar reenter = Calendar.getInstance(); reenter.set(Calendar.MINUTE, RESET_MIN); // if time is >= RESET_HOUR - roll to the next day if (reenter.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR) reenter.add(Calendar.DATE, 1); reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR); SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED); sm.addInstanceName(world.templateId); // set instance reenter time for all allowed players for (int objectId : world.allowed) { L2PcInstance obj = L2World.getInstance().getPlayer(objectId); if (obj != null && obj.isOnline()) { InstanceManager.getInstance() .setInstanceTime(objectId, world.templateId, reenter.getTimeInMillis()); obj.sendPacket(sm); } } // destroy instance after EXIT_TIME Instance inst = InstanceManager.getInstance().getInstance(world.instanceId); inst.setDuration(EXIT_TIME * 60000); inst.setEmptyDestroyTime(0); } }
@Override protected void runImpl() { L2PcInstance player = getClient().getActiveChar(); if (player == null) return; if (_items == null) { sendPacket(ActionFailed.STATIC_PACKET); return; } if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("privatestoresell")) { player.sendMessage("You are selling items too fast."); return; } L2PcInstance object = L2World.getInstance().getPlayer(_storePlayerId); if (object == null) return; L2PcInstance storePlayer = object; if (!player.isInsideRadius(storePlayer, INTERACTION_DISTANCE, true, false)) return; if (player.getInstanceId() != storePlayer.getInstanceId() && player.getInstanceId() != -1) return; if (storePlayer.getPrivateStoreType() != L2PcInstance.STORE_PRIVATE_BUY) return; if (player.isCursedWeaponEquipped()) return; TradeList storeList = storePlayer.getBuyList(); if (storeList == null) return; if (!player.getAccessLevel().allowTransaction()) { player.sendMessage("Transactions are disabled for your Access Level."); sendPacket(ActionFailed.STATIC_PACKET); return; } if (!storeList.privateStoreSell(player, _items)) { sendPacket(ActionFailed.STATIC_PACKET); _log.warning( "PrivateStore sell has failed due to invalid list or request. Player: " + player.getName() + ", Private store of: " + storePlayer.getName()); return; } if (storeList.getItemCount() == 0) { storePlayer.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE); storePlayer.broadcastUserInfo(); } }