Jump to content
  • 0

Making The Code Execute


Question

Posted

Greetings mxc community,

 

This is will be the most silly question that you'd ever heard from someone and apologize for that..

 

I will try to demonstrate my issue so you guys can clearly understand it.

 

Let's say that i have the following class inside one package 

public class Demonstration {

  public Demonstration() {
    }
  
  public void doStuff() {
    //code
    }

Normally i'd create a new  Demonstration object inside the Main class to call its method. However, when it comes to l2j i dont know how to actually execute the code from inside the game.

 

I can write newbie code but i cant even test if it is actually working!

 

Any help would be highly appreciated

 

Thank you

11 answers to this question

Recommended Posts

  • 0
Posted

depends on when you want it to execute?

 

Server startup ? Gameserver.java

PvP kill? L2PcInstance dodie or increasePvPKills methods

 

keep in mind that the doStuff method must be static to be accessed or you need a new Instance of the object or more simply an instanceholder

  • 0
Posted

You have to know the action that executes what you want for example if you want a simple message to show up when you pick up whatever stuff you put your code into the pickUpMe() or whatever its name or you can put it into the addItem method since its called on inventory update or even add it to the getItem packet. Mostly you need to experiment where its better to put it but thats the wasiest way, try to avoid creating a lot of small classes for tiny bit of things.

  • 0
Posted

It entirely depends of what you want to do.

 

Basically you got the possibility to :

  • instantiate a class, such as L2PcInstance, holding different parameters for different players. You create a new object, fill infos, destroy the object.
  • "static-fied" the class using a singleton, such as any datatable holding structure, in order to get a unique reference of that class. You access it using "ClassName.getInstance().methodName()". You laso have the possibility to use static keyword on a method if all parameters are passed on the method, and it doesn't use any class variable (or until it static aswell).

Tell what you want to do.

  • 0
Posted

Oh, i see

 

Let's say that i want to PM - spam each online player over a random amount a time, Would the following code actually do something if i initialize it first in gameserver class as a thread?


public class Demonstration implements Runnable {
  
  private L2PCInstance activeChar;
 
    public Demonstration() {
      activeChar = ??? // How do i actually initialize this variable to represent each online player? :(
    }
  
  public void doStuff() {
    activeChar.sendPMMethod("This is just a test");
    }

  public void run() {
    doStuff();
    Thread.sleep(new Random().nextInt(5000));
    }
}

Thanks for your replies guys :)

  • 0
Posted (edited)

I guess you could do it like that. You could put it under doStuff() and delete Demonstaration() ? Correct me if I'm wrong.. :P

        CreatureSay cs = new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), text);
        
        Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
        
        for (L2PcInstance player : pls)
            player.sendPacket(cs);
        
        activeChar.sendPacket(cs);
Edited by SweeTs
  • 0
Posted

Yah.. so true, then it becomes 1 line :P

 

 

Broadcast.toAllOnlinePlayers(new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), text));
  • 0
Posted (edited)

TreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> {Broadcast.toAllOnline(new CreatureSay(blabla)}); java8 

 

Oh, i see

 

Let's say that i want to PM - spam each online player over a random amount a time, Would the following code actually do something if i initialize it first in gameserver class as a thread?


public class Demonstration implements Runnable {
  
  private L2PCInstance activeChar;
 
    public Demonstration() {
      activeChar = ??? // How do i actually initialize this variable to represent each online player? :(
    }
  
  public void doStuff() {
    activeChar.sendPMMethod("This is just a test");
    }

  public void run() {
    doStuff();
    Thread.sleep(new Random().nextInt(5000));
    }
}

Thanks for your replies guys :)

 

Even if that was the way your constructor misses the L2PcInstance parameter to initialize your var

Edited by xdem
  • 0
Posted

 

Yah.. so true, then it becomes 1 line :P

Broadcast.toAllOnlinePlayers(new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), text));

 

 

its still the same code ;p

  • 0
Posted

its still the same code ;p

Yup, that was the point to reduce the code, from let's say 10 lines to 1 hue :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ✔ We offer more services than listed. Prices of goods may vary depending on country, warranty, phone number, and other factors. We are available 24/7. ⠀⠀⠀⠀⠀⠀⣀⣠⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⣴⡿⠋⠉⠉⠻⢿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠹⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠈⣿⡄⠀⠀⠀⠀⠀⠀⢸⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⢀⣀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⢻⣇⠀⠀⠀⠀⠀⢸⣿⣿⡿⠿⠿⠟⠛⠛⠻⢿⣿⣶⣄⠀⠀⠀ ⠀⠀⠀⠀⠀⢈⣿⠆⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣤⣤⣤⠀⠈⠻⣿⣇⠀⠀ ⠀⠀⠀⠀⢀⣾⡏⠀⠀⠀⠀⠀⠀⠀⣴⡿⠋⠉⠀⠀⠀⠀⠀⠀⠀⢹⡿⠀⠀ ⠀⠀⣀⣤⣼⣿⠀⠀⠀⠀⠀⠀⠀⢸⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⣷⣄⠀ ⢠⣾⠟⠋⠉⠋⠀⠀⠀⠀⠀⠀⠀⠈⣿⣦⣀⣀⣀⣤⣤⣶⣶⠿⠋⠁⢹ ⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡟⢉⣿⠋⠉⠉⠉⠁⠀⠀⠀⠀⢸⣿⠀ ⢸⣿⠀⠀⠀⠀⠀⢀⣀⣀⣤⣴⠿⠋⠀⠘⣷⡀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠏⠀ ⢸⣿⡄⠀⠀⠀⠀⠈⠉⠉⠁⠀⠀⠀⠀⠀⣸⣿⢶⣤⣤⣴⡶⠿⠛⠙⣿ ⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⣽⣿⠀ ⠀⠘⣿⣆⠀⠀⠀⠀⣠⣤⡀⠀⠀⠀⠀⠈⠻⣧⣀⡀⠀⠀⠀⣀⣠⣴⡿⠇⠀ ⠀⠀⠘⢿⣿⣦⣤⣴⡿⠻⠿⣷⣦⣤⣤⣤⣴⣾⣿⡿⠿⠿⠿⠟⠛⠉⠀⠀⠀ ⠀⠀⠀⠀⠀⠀
    • Frozen is more popular coz adm can edit npc from client side and no need dig in xml and etc  )
    • Your work is as good as your arrogance. If you didn't break 10 systems to fix 1, I would recommend aCis. Yes, I use aCis and I fixed a lot of things that you left aside to reorganize and rename things. You insist on recommending your broken public project. Don't do that because there are many people who dream of owning a server, and in aCis 409 every dream is broken. I've seen many people break things by using this. aCis 409 doesn't work at the basics. Water movement and flying movements are broken, which is the basics. Seven Sings is completely broken, Sieges need fixing, and worst of all, level 3 and 4 clan quests are bugged, besides other quests that you intentionally broke and still recommend. You are an excellent programmer, but your arrogance in feeling superior to everyone is killing you. Happy New Year to you, and be more transparent and honest when recommending this. I'm not sharing the corrections I made, nor my Geodata system, precisely because of your arrogance. I'll soon post a video of my Geoengine system, which you spent 12 years on and didn't finish. I can send you a list of everything you need to fix, but you're too arrogant for that because you're a superior God and don't accept advice from mortals.
    • Changelog   All notable changes to this project will be documented in this file. [English Version](#english-version) | [Versión en Español](#versión-en-español)   ---   English Version   [1.1.3] - 2026-01-05   Added   Donation System Integration - Integrated comprehensive donation panel into the main CMS - Implemented direct donation system without requiring user login - Added automatic coin crediting directly to character inventory - Created new React component for donation interface with modern design - Implemented real-time coin calculation based on payment method and currency - Added support for multiple payment gateways:   - MercadoPago (ARS)   - PayPal (USD, BRL, EUR)   - PagSeguro (BRL) - Developed new backend endpoint for processing direct donations - Implemented character validation system before payment processing - Added automatic webhook handling for payment confirmations - Created comprehensive logging system for all donation transactions - Implemented bonus system for bulk coin purchases - Added donation history tracking and management   Vote Reward System - Integrated vote reward panel into the CMS - Implemented multi-topsite voting system - Added automatic reward delivery upon vote verification - Created vote tracking and cooldown management - Implemented anti-fraud measures for vote validation - Added vote history and statistics for users - Developed admin panel for vote reward configuration - Implemented automatic vote verification through topsite APIs   Database Enhancements - Created new table structure for donation management (`site_donations`) - Added `auto_credit` field for automatic coin delivery - Implemented balance tracking system (`site_balance`) - Created conversion and transfer logging tables - Added comprehensive indexing for performance optimization - Implemented transaction history tracking   Frontend Improvements - Developed new donation panel component with consistent site design - Added multi-language support (Spanish, English, Portuguese) - Implemented form validation and error handling - Created responsive design for mobile and desktop - Added real-time price calculation display - Implemented loading states and user feedback messages   Backend Infrastructure - Created secure API endpoints for donation processing - Implemented webhook system for payment gateway integration - Added comprehensive error logging and debugging tools - Developed configuration management system - Implemented security measures for sensitive data handling - Added support for sandbox and production environments   Documentation - Created comprehensive production setup guide - Developed security checklist for deployment - Added database setup scripts with detailed instructions - Created API integration documentation - Developed troubleshooting guides - Added configuration examples for all payment gateways   Changed - Updated navigation system to include donation and vote panels - Modified routing to support new panel pages - Enhanced translation system with new text strings - Improved error handling across the application - Updated proxy configuration for backend communication   Security - Implemented credential protection in configuration files - Added example configuration files without sensitive data - Created .htaccess rules for protecting sensitive directories - Implemented webhook signature validation - Added SQL injection prevention measures - Implemented session security enhancements   Technical Details - React 19.2.0 for frontend components - TypeScript for type safety - Vite 6.2.0 for build tooling - PHP 7.4+ for backend processing - SQL Server 2012+ for database management - Integration with MercadoPago SDK - RESTful API architecture   ---   Versión en Español   [1.1.3] - 2026-01-05   Agregado   Integración del Sistema de Donaciones - Integración completa del panel de donaciones al CMS principal - Implementación de sistema de donaciones directas sin requerir inicio de sesión - Agregada acreditación automática de coins directamente al inventario del personaje - Creación de nuevo componente React para interfaz de donaciones con diseño moderno - Implementación de cálculo de coins en tiempo real según método de pago y moneda - Agregado soporte para múltiples pasarelas de pago:   - MercadoPago (ARS)   - PayPal (USD, BRL, EUR)   - PagSeguro (BRL) - Desarrollo de nuevo endpoint backend para procesamiento de donaciones directas - Implementación de sistema de validación de personajes antes del procesamiento de pago - Agregado manejo automático de webhooks para confirmaciones de pago - Creación de sistema completo de logs para todas las transacciones de donación - Implementación de sistema de bonos para compras de coins en volumen - Agregado seguimiento y gestión de historial de donaciones   Sistema de Recompensas por Votación - Integración del panel de recompensas por votación al CMS - Implementación de sistema de votación multi-topsite - Agregada entrega automática de recompensas al verificar votos - Creación de seguimiento de votos y gestión de tiempos de espera - Implementación de medidas anti-fraude para validación de votos - Agregado historial de votos y estadísticas para usuarios - Desarrollo de panel administrativo para configuración de recompensas - Implementación de verificación automática de votos mediante APIs de topsites   Mejoras en Base de Datos - Creación de nueva estructura de tablas para gestión de donaciones (`site_donations`) - Agregado campo `auto_credit` para entrega automática de coins - Implementación de sistema de seguimiento de balance (`site_balance`) - Creación de tablas de registro de conversiones y transferencias - Agregada indexación completa para optimización de rendimiento - Implementación de seguimiento de historial de transacciones   Mejoras en Frontend - Desarrollo de nuevo componente de panel de donaciones con diseño consistente - Agregado soporte multi-idioma (Español, Inglés, Portugués) - Implementación de validación de formularios y manejo de errores - Creación de diseño responsive para móvil y escritorio - Agregada visualización de cálculo de precios en tiempo real - Implementación de estados de carga y mensajes de retroalimentación al usuario   Infraestructura Backend - Creación de endpoints API seguros para procesamiento de donaciones - Implementación de sistema de webhooks para integración con pasarelas de pago - Agregadas herramientas completas de registro de errores y depuración - Desarrollo de sistema de gestión de configuración - Implementación de medidas de seguridad para manejo de datos sensibles - Agregado soporte para entornos sandbox y producción   Documentación - Creación de guía completa de configuración para producción - Desarrollo de checklist de seguridad para despliegue - Agregados scripts de configuración de base de datos con instrucciones detalladas - Creación de documentación de integración de APIs - Desarrollo de guías de solución de problemas - Agregados ejemplos de configuración para todas las pasarelas de pago   Modificado - Actualización del sistema de navegación para incluir paneles de donación y votación - Modificación del enrutamiento para soportar nuevas páginas de paneles - Mejora del sistema de traducciones con nuevas cadenas de texto - Mejora del manejo de errores en toda la aplicación - Actualización de configuración de proxy para comunicación con backend   Seguridad - Implementación de protección de credenciales en archivos de configuración - Agregados archivos de configuración de ejemplo sin datos sensibles - Creación de reglas .htaccess para proteger directorios sensibles - Implementación de validación de firma de webhooks - Agregadas medidas de prevención de inyección SQL - Implementación de mejoras de seguridad en sesiones   Detalles Técnicos - React 19.2.0 para componentes frontend - TypeScript para seguridad de tipos - Vite 6.2.0 para herramientas de construcción - PHP 7.4+ para procesamiento backend - SQL Server 2012+ para gestión de base de datos - Integración con SDK de MercadoPago - Arquitectura API RESTful   ---   Migration Notes / Notas de Migración   For Existing Installations / Para Instalaciones Existentes   **English:** If you are upgrading from a previous version, please follow these steps: 1. Backup your database before applying any changes 2. Run the database migration script (`database_setup.sql`) 3. Update your configuration file with new settings 4. Configure payment gateway credentials 5. Test the donation flow in sandbox mode before going to production 6. Review the security checklist before deployment   **Español:** Si está actualizando desde una versión anterior, siga estos pasos: 1. Realice una copia de seguridad de su base de datos antes de aplicar cambios 2. Ejecute el script de migración de base de datos (`database_setup.sql`) 3. Actualice su archivo de configuración con las nuevas opciones 4. Configure las credenciales de las pasarelas de pago 5. Pruebe el flujo de donaciones en modo sandbox antes de pasar a producción 6. Revise el checklist de seguridad antes del despliegue   ---   Known Issues / Problemas Conocidos   **English:** - Webhook notifications may experience delays during high traffic periods - Some payment gateways require manual configuration of webhook URLs - Character names are case-sensitive in the donation form   **Español:** - Las notificaciones de webhook pueden experimentar retrasos durante períodos de alto tráfico - Algunas pasarelas de pago requieren configuración manual de URLs de webhook - Los nombres de personajes son sensibles a mayúsculas/minúsculas en el formulario de donación   ---   Roadmap / Hoja de Ruta   Planned Features / Características Planeadas   **English:** - Admin dashboard for donation management - Automated refund processing - Subscription-based donations - Gift card system - Enhanced reporting and analytics - Mobile application support   **Español:** - Panel administrativo para gestión de donaciones - Procesamiento automatizado de reembolsos - Donaciones basadas en suscripción - Sistema de tarjetas de regalo - Reportes y análisis mejorados - Soporte para aplicación móvil   ---   Contributors / Contribuidores   This release includes contributions from the development team focused on creating a secure, user-friendly donation and voting system integrated seamlessly with the existing CMS.   Este lanzamiento incluye contribuciones del equipo de desarrollo enfocado en crear un sistema de donaciones y votación seguro y fácil de usar, integrado perfectamente con el CMS existente.   ---   Support / Soporte   **English:** For issues, questions, or feature requests, please refer to: - `PRODUCTION_SETUP_GUIDE.md` for setup instructions - `SECURITY_CHECKLIST.md` for security guidelines - `DONATION_DIRECT_SYSTEM.md` for technical documentation   **Español:** Para problemas, preguntas o solicitudes de características, consulte: - `PRODUCTION_SETUP_GUIDE.md` para instrucciones de configuración - `SECURITY_CHECKLIST.md` para pautas de seguridad - `DONATION_DIRECT_SYSTEM.md` para documentación técnica   ---   License / Licencia   This project maintains its original licensing terms. Please refer to the LICENSE file for details.   Este proyecto mantiene sus términos de licencia originales. Consulte el archivo LICENSE para más detalles.   ---   **Last Updated / Última Actualización:** January 5, 2026   **Version / Versión:** 1.1.3
    • Dragonic 2 – High Five is a fully custom private server, built with an original visual identity and integrated premium systems. We offer a stable, modern, and optimized experience, combining classic High Five gameplay with new features created especially for the community. The server is live and available to all players. You can access the official website here:  https://dragonic2.com/ If you encounter any bugs or issues, please report them so we can fix them as quickly as possible. Join the adventure and discover Dragonic 2 — High Five.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock