TransformationManager.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.instancemanager;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import java.util.logging.Logger;
  23. import com.l2jserver.gameserver.model.L2Transformation;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. /**
  26. * @author KenM
  27. */
  28. public class TransformationManager
  29. {
  30. private static final Logger _log = Logger.getLogger(TransformationManager.class.getName());
  31. private final Map<Integer, L2Transformation> _transformations = new HashMap<>();
  32. protected TransformationManager()
  33. {
  34. }
  35. public void report()
  36. {
  37. _log.info(getClass().getSimpleName() + ": Loaded: " + _transformations.size() + " transformations.");
  38. }
  39. public boolean transformPlayer(int id, L2PcInstance player)
  40. {
  41. L2Transformation template = 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. public static TransformationManager getInstance()
  59. {
  60. return SingletonHolder._instance;
  61. }
  62. private static class SingletonHolder
  63. {
  64. protected static final TransformationManager _instance = new TransformationManager();
  65. }
  66. }