2
0

TransformationManager.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 java.util.HashMap;
  17. import java.util.Map;
  18. import java.util.logging.Logger;
  19. import com.l2jserver.gameserver.model.L2Transformation;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. /**
  22. * @author KenM
  23. */
  24. public class TransformationManager
  25. {
  26. private static final Logger _log = Logger.getLogger(TransformationManager.class.getName());
  27. private final Map<Integer, L2Transformation> _transformations = new HashMap<>();
  28. protected TransformationManager()
  29. {
  30. }
  31. public void report()
  32. {
  33. _log.info(getClass().getSimpleName() + ": Loaded: " + _transformations.size() + " transformations.");
  34. }
  35. public boolean transformPlayer(int id, L2PcInstance player)
  36. {
  37. L2Transformation template = getTransformationById(id);
  38. if (template != null)
  39. {
  40. L2Transformation trans = template.createTransformationForPlayer(player);
  41. trans.start();
  42. return true;
  43. }
  44. return false;
  45. }
  46. public L2Transformation getTransformationById(int id)
  47. {
  48. return _transformations.get(id);
  49. }
  50. public L2Transformation registerTransformation(L2Transformation transformation)
  51. {
  52. return _transformations.put(transformation.getId(), transformation);
  53. }
  54. public static TransformationManager getInstance()
  55. {
  56. return SingletonHolder._instance;
  57. }
  58. private static class SingletonHolder
  59. {
  60. protected static final TransformationManager _instance = new TransformationManager();
  61. }
  62. }