TransformationManager.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.instancemanager;
  16. import gnu.trove.TIntObjectHashMap;
  17. import java.util.logging.Logger;
  18. import com.l2jserver.gameserver.model.L2Transformation;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. /**
  21. * @author KenM
  22. */
  23. public class TransformationManager
  24. {
  25. private static final Logger _log = Logger.getLogger(TransformationManager.class.getName());
  26. public static TransformationManager getInstance()
  27. {
  28. return SingletonHolder._instance;
  29. }
  30. private TIntObjectHashMap<L2Transformation> _transformations;
  31. private TransformationManager()
  32. {
  33. _transformations = new TIntObjectHashMap<L2Transformation>();
  34. }
  35. public void report()
  36. {
  37. _log.info("Loaded: " + _transformations.size() + " transformations.");
  38. }
  39. public boolean transformPlayer(int id, L2PcInstance player)
  40. {
  41. L2Transformation template = this.getTransformationById(id);
  42. if (template != null)
  43. {
  44. L2Transformation trans = template.createTransformationForPlayer(player);
  45. trans.start();
  46. return true;
  47. }
  48. return false;
  49. }
  50. public L2Transformation getTransformationById(int id)
  51. {
  52. return _transformations.get(id);
  53. }
  54. public L2Transformation registerTransformation(L2Transformation transformation)
  55. {
  56. return _transformations.put(transformation.getId(), transformation);
  57. }
  58. @SuppressWarnings("synthetic-access")
  59. private static class SingletonHolder
  60. {
  61. protected static final TransformationManager _instance = new TransformationManager();
  62. }
  63. }