Ejemplo n.º 1
0
  @Override
  public void onEnable() {

    colors = new ArrayList<>();
    colors.add(ChatColor.AQUA);
    colors.add(ChatColor.BLACK);
    colors.add(ChatColor.BLUE);
    colors.add(ChatColor.DARK_AQUA);
    colors.add(ChatColor.DARK_BLUE);
    colors.add(ChatColor.DARK_GRAY);
    colors.add(ChatColor.DARK_GREEN);
    colors.add(ChatColor.DARK_PURPLE);
    colors.add(ChatColor.DARK_RED);
    colors.add(ChatColor.GOLD);
    colors.add(ChatColor.GRAY);
    colors.add(ChatColor.GREEN);
    colors.add(ChatColor.LIGHT_PURPLE);
    colors.add(ChatColor.RED);
    colors.add(ChatColor.WHITE);
    colors.add(ChatColor.YELLOW);
    rand = new Random();
    File cfile = new File(getDataFolder(), "config.yml");
    if (!cfile.exists()) {
      getConfig().options().copyDefaults(true);
      saveConfig();
    }

    getLogger().info("Registering Deserialization Classes");
    ConfigurationSerialization.registerClass(WarpZone.class);
    ConfigurationSerialization.registerClass(Furnace.class);
    ConfigurationSerialization.registerClass(Shaped.class);
    ConfigurationSerialization.registerClass(Shapeless.class);
    getLogger().info("Done Registering Deserialization Classes");

    config = new Configuration(this);
    config.load();

    getServer().getPluginManager().registerEvents(new Omneity3Listener(this), this);
    getServer().getPluginManager().registerEvents(new PortalListener(this), this);
    getServer().getPluginManager().registerEvents(new FirstJoinListener(this), this);
    getServer().getPluginManager().registerEvents(new WarpZoneListener(this), this);
    getServer().getPluginManager().registerEvents(new SpawnListener(this), this);
    getServer().getPluginManager().registerEvents(new petKillListener(this), this);
    loadRecipes();

    blockedEntities = new ArrayList<>();
    blockedEntities.add(EntityType.ITEM_FRAME);
    blockedEntities.add(EntityType.FALLING_BLOCK);
    blockedEntities.add(EntityType.PLAYER);
    blockedEntities.add(EntityType.MINECART);
    blockedEntities.add(EntityType.BOAT);
    blockedEntities.add(EntityType.COMPLEX_PART);
    blockedEntities.add(EntityType.UNKNOWN);
    blockedEntities.add(EntityType.DROPPED_ITEM);

    this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
    bungeePluginChannel = new DataOutputStream(new ByteArrayOutputStream());
  }
Ejemplo n.º 2
0
 @Override
 public void onEnable() {
   ConfigurationSerialization.registerClass(Message.class, "Message");
   instance = this;
   getServer().getPluginManager().registerEvents(this, this);
   init();
 }
Ejemplo n.º 3
0
    public Node representData(Object data) {
      final ConfigurationSerializable serializable = (ConfigurationSerializable) data;
      final Map<String, Object> values = new LinkedHashMap<String, Object>();
      values.put(
          ConfigurationSerialization.SERIALIZED_TYPE_KEY,
          ConfigurationSerialization.getAlias(serializable.getClass()));
      values.putAll(serializable.serialize());

      return super.representData(values);
    }
Ejemplo n.º 4
0
  public void setClass(final String name, final Class<?> clazz) {
    if (!classes.containsKey(name)) {
      classes.put(name, clazz);

      if (ConfigurationSerializable.class.isAssignableFrom(clazz)) {
        Class<? extends ConfigurationSerializable> serializable =
            (Class<? extends ConfigurationSerializable>) clazz;
        ConfigurationSerialization.registerClass(serializable);
      }
    }
  }
Ejemplo n.º 5
0
  public void removeClass(String name) {
    Class<?> clazz = classes.remove(name);

    try {
      if ((clazz != null) && (ConfigurationSerializable.class.isAssignableFrom(clazz))) {
        Class<? extends ConfigurationSerializable> serializable =
            (Class<? extends ConfigurationSerializable>) clazz;
        ConfigurationSerialization.unregisterClass(serializable);
      }
    } catch (NullPointerException ex) {
      // Boggle!
      // (Native methods throwing NPEs is not fun when you can't stop it before-hand)
    }
  }
  public NewWirelessConfiguration(WirelessRedstone r_plugin) {
    plugin = r_plugin;

    // Initialize the serialization
    ConfigurationSerialization.registerClass(WirelessReceiver.class, "WirelessReceiver");
    ConfigurationSerialization.registerClass(WirelessTransmitter.class, "WirelessTransmitter");
    ConfigurationSerialization.registerClass(WirelessChannel.class, "WirelessChannel");
    ConfigurationSerialization.registerClass(WirelessScreen.class, "WirelessScreen");

    // Loading and saving
    getConfig().options().copyDefaults(true);
    plugin.saveConfig();
    reloadConfig();

    // Try to know if the config is an OldConfiguration, and convert it
    File oldConfig = new File(plugin.getDataFolder(), "settings.yml");
    if (oldConfig.exists()) {
      convertOldConfigToNew(oldConfig);
    }

    // Language selection

  }
Ejemplo n.º 7
0
  /**
   * Creates a new server on TCP port 25565 and starts listening for connections.
   *
   * @param args The command-line arguments.
   */
  public static void main(String[] args) {
    try {
      storeQueue.start();

      if (!configDir.exists() || !configDir.isDirectory()) configDir.mkdirs();
      config.load();
      config.options().indent(4);
      ConfigurationSerialization.registerClass(GlowOfflinePlayer.class);

      GlowServer server = new GlowServer();
      server.start();
      List<String> binds = config.getStringList("server.bind");
      boolean hasBound = false;
      if (binds != null) {
        for (String bind : binds) {
          String[] split = bind.split("@");
          if (split.length != 2) {
            split = bind.split(":");
          }
          if (split.length > 2) continue;
          int port = 25565;
          try {
            if (split.length > 1) {
              port = Integer.parseInt(split[1]);
            }
          } catch (NumberFormatException e) {
          }
          server.bind(new InetSocketAddress(split[0], port));
          hasBound = true;
        }
      }
      if (!hasBound) {
        server.bind(new InetSocketAddress(config.getInt("server.port", 25565)));
      }
      logger.info("Ready for connections.");
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Error during server startup.", t);
    }
  }
Ejemplo n.º 8
0
  /**
   * Creates a new server on TCP port 25565 and starts listening for connections.
   *
   * @param args The command-line arguments.
   */
  public static void main(String[] args) {
    try {
      ConfigurationSerialization.registerClass(GlowOfflinePlayer.class);
      GlowPotionEffect.register();

      // parse arguments and read config
      final ServerConfig config = parseArguments(args);
      if (config == null) {
        return;
      }

      // start server
      final GlowServer server = new GlowServer(config);
      server.start();
      server.bind();
      server.bindQuery();
      server.bindRcon();
      logger.info("Ready for connections.");
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Error during server startup.", t);
      System.exit(1);
    }
  }
Ejemplo n.º 9
0
 /** Registers all the serializable classes to serialize them. */
 private void registerSerializations() {
   ConfigurationSerialization.registerClass(City.class);
   ConfigurationSerialization.registerClass(District.class);
   ConfigurationSerialization.registerClass(MWorld.class);
 }
Ejemplo n.º 10
0
 static {
   ConfigurationSerialization.registerClass(FancyMessage.class);
 }
 public VotifierItemsPlugin() {
   ConfigurationSerialization.registerClass(Item.class);
 }
Ejemplo n.º 12
0
 static {
   ConfigurationSerialization.registerClass(Mine.class);
 }
Ejemplo n.º 13
0
 private void registerConfigurationClasses() {
   ConfigurationSerialization.registerClass(RessourceSpawner.class, "RessourceSpawner");
   ConfigurationSerialization.registerClass(Team.class, "Team");
 }
 static {
   ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class);
   ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class);
 }
Ejemplo n.º 15
0
  @Override
  public void onEnable() {

    if (!new File(getDataFolder(), "config.yml").exists()) {
      Message.log("Config.yml not found. Creating a one for you.");
      getConfig().options().copyDefaults(true);
      saveConfig();
      crashed = true;
      this.setEnabled(false);
      return;
    }

    if (LocalConfiguration.FetchPatches.asBoolean()) new PatchFetcher();
    new Query();

    try {
      new Database();
    } catch (Exception e) {
      crashed = true;
      Message.log(Level.SEVERE, "Cannot establish a database connection!");
      Message.log(Level.SEVERE, "Is the plugin set up correctly?");
      if (LocalConfiguration.Debug.asBoolean()) e.printStackTrace();
      this.setEnabled(false);
      return;
    }

    Message.log("Database connection established.");

    if (getServer().getPluginManager().getPlugin("Vault") != null && Module.Vault.isEnabled()) {
      vaultHook = new VaultHook();
      vaultHook.onEnable();
    }

    if (getServer().getPluginManager().getPlugin("WorldGuard") != null
        && getServer().getPluginManager().getPlugin("WorldEdit") != null
        && Module.WorldGuard.isEnabled()) {
      worldGuardHook = new WorldGuardHook();
      worldGuardHook.onEnable();
    }

    ConfigurationSerialization.registerClass(StatsSign.class, "StatsSign");

    new ServerListener(this);
    new PlayerListener(this);
    if (Module.Blocks.isEnabled()) new BlockListener(this);
    if (Module.Items.isEnabled()) new ItemListener(this);
    if (Module.Deaths.isEnabled()) new DeathListener(this);
    new StatsSignListener(this);
    if (isCraftBukkitCompatible()) new StatsBookListener(this);

    serverStatistics = new ServerStatistics();
    serverTotals = new ServerTotals();

    long ping = RemoteConfiguration.Ping.asInteger() * 20;

    try {
      metrics = new PluginMetrics(this);
      if (!metrics.isOptOut()) metrics.start();
    } catch (IOException e) {
      Message.log(Level.SEVERE, "An error occurred while connecting to PluginMetrics");
    }

    CachedData.startAll();

    Bukkit.getScheduler().runTaskTimerAsynchronously(this, new DatabaseTask(), (ping / 2), ping);
    Bukkit.getScheduler().runTaskTimerAsynchronously(this, new RefreshTask(), 0L, 20L);

    Bukkit.getScheduler().runTaskTimer(this, new SignRefreshTask(), ping, ping);
    Bukkit.getScheduler().runTaskTimer(this, new TickTask(), 0L, 1L);
  }