Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. package de.photon.AACAdditionPro.modules.clientcontrol;
  2.  
  3. import com.google.common.collect.ImmutableSet;
  4. import de.photon.AACAdditionPro.AACAdditionPro;
  5. import de.photon.AACAdditionPro.ServerVersion;
  6. import de.photon.AACAdditionPro.modules.ListenerModule;
  7. import de.photon.AACAdditionPro.modules.ModuleType;
  8. import de.photon.AACAdditionPro.modules.PluginMessageListenerModule;
  9. import de.photon.AACAdditionPro.modules.RestrictedServerVersion;
  10. import de.photon.AACAdditionPro.user.User;
  11. import de.photon.AACAdditionPro.user.UserManager;
  12. import de.photon.AACAdditionPro.util.pluginmessage.MessageChannel;
  13. import java.io.ByteArrayOutputStream;
  14. import java.io.DataOutputStream;
  15. import java.io.IOException;
  16. import java.util.Objects;
  17. import java.util.Set;
  18. import org.bukkit.configuration.file.FileConfiguration;
  19. import org.bukkit.entity.Player;
  20. import org.bukkit.event.EventHandler;
  21. import org.bukkit.event.player.PlayerJoinEvent;
  22.  
  23. public class SchematicaControl
  24. extends ClientControlModule
  25. implements ListenerModule, PluginMessageListenerModule, RestrictedServerVersion
  26. {
  27. private static final MessageChannel SCHEMATICA_CHANNEL = new MessageChannel("minecraft", "schematica", "schematica");
  28. private final boolean[] disable = {
  29. !AACAdditionPro.getInstance().getConfig().getBoolean(getModuleType().getConfigString() + ".disable.printer") ? 1 : 0,
  30. !AACAdditionPro.getInstance().getConfig().getBoolean(getModuleType().getConfigString() + ".disable.saveToFile") ? 1 : 0,
  31. !AACAdditionPro.getInstance().getConfig().getBoolean(getModuleType().getConfigString() + ".disable.load") ? 1 : 0 };
  32.  
  33. @EventHandler
  34. public void on(PlayerJoinEvent paramPlayerJoinEvent)
  35. {
  36. User localUser = UserManager.getUser(paramPlayerJoinEvent.getPlayer().getUniqueId());
  37. if (User.isUserInvalid(localUser, getModuleType())) {
  38. return;
  39. }
  40. try
  41. {
  42. ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();Object localObject1 = null;
  43. try
  44. {
  45. DataOutputStream localDataOutputStream = new DataOutputStream(localByteArrayOutputStream);Object localObject2 = null;
  46. try
  47. {
  48. localDataOutputStream.writeByte(0);
  49. for (int k : this.disable) {
  50. localDataOutputStream.writeBoolean(k);
  51. }
  52. localUser.getPlayer().sendPluginMessage(AACAdditionPro.getInstance(), SCHEMATICA_CHANNEL
  53. .getChannel(),
  54. (byte[])Objects.requireNonNull(localByteArrayOutputStream.toByteArray(), "Schematica plugin message is null"));
  55. }
  56. catch (Throwable localThrowable4)
  57. {
  58. localObject2 = localThrowable4;throw localThrowable4;
  59. }
  60. finally {}
  61. }
  62. catch (Throwable localThrowable2)
  63. {
  64. localObject1 = localThrowable2;throw localThrowable2;
  65. }
  66. finally
  67. {
  68. if (localByteArrayOutputStream != null) {
  69. if (localObject1 != null) {
  70. try
  71. {
  72. localByteArrayOutputStream.close();
  73. }
  74. catch (Throwable localThrowable6)
  75. {
  76. ((Throwable)localObject1).addSuppressed(localThrowable6);
  77. }
  78. } else {
  79. localByteArrayOutputStream.close();
  80. }
  81. }
  82. }
  83. }
  84. catch (IOException localIOException)
  85. {
  86. localIOException.printStackTrace();
  87. }
  88. }
  89.  
  90. public Set<MessageChannel> getOutgoingChannels()
  91. {
  92. return ImmutableSet.of(SCHEMATICA_CHANNEL);
  93. }
  94.  
  95. public ModuleType getModuleType()
  96. {
  97. return ModuleType.SCHEMATICA_CONTROL;
  98. }
  99.  
  100. public Set<ServerVersion> getSupportedVersions()
  101. {
  102. return ServerVersion.LEGACY_PLUGIN_MESSAGE_VERSIONS;
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement