Support for 1.8

Discussion in 'Programming' started by Bio, Aug 14, 2019.

Thread Status:
Not open for further replies.
  1. Bio

    Bio

    I'm trying to make a plugin for particles, it works from 1.9 to 1.14
    I want it to work for 1.8 but i don't know how to do it

    Code:
    Surprise.java
    Code (Java):
    package me.bhz.surprise.surprise;

    import commands.Particle;
    import org.bukkit.ChatColor;
    import org.bukkit.plugin.java.JavaPlugin;

    public final class Surprise extends JavaPlugin {

        String prefix = "[Surprise] ";

        @Override
        public void onEnable() {
            System.out.println(ChatColor.GREEN + prefix + "Loaded successfully");
            getConfig().options().copyDefaults();
            getCommand("surprise").setExecutor((new Particle()));
            saveDefaultConfig();

        }

        @Override
        public void onDisable() {
            System.out.println((ChatColor.GREEN + prefix + "Disabled successfully"));
        }

    }
     
    Particle.java
    Code (Java):
    package commands;

    import me.bhz.surprise.surprise.Surprise;
    import org.bukkit.*;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.Plugin;

    public class Particle implements CommandExecutor {
        private Plugin plugin = Surprise.getPlugin(Surprise.class);

        private static final String ADMIN_PERM = "surprise.admin";
        private String prefix = plugin.getConfig().getString("prefix");

        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(sender.hasPermission(ADMIN_PERM)) {
                if (args.length == 1) {
                    String target_name = args[0];
                    Player target = Bukkit.getPlayer(target_name);
                    if (target != null) {
                            surprisePlayer(target);
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&',prefix + plugin.getConfig().getString("received").replace("%player%", target_name)));
                    } else {
                        sender.sendMessage(ChatColor.translateAlternateColorCodes('&',prefix + plugin.getConfig().getString("offline")));
                    }
                } else {
                    return false;
                }
            } else sender.sendMessage(ChatColor.translateAlternateColorCodes('&',plugin.getConfig().getString("noperm")));
            return true;
        }


        private void surprisePlayer(Player who) {
                who.spawnParticle(Particle.REDSTONE, who.getLocation(), 10);
        }
    }


     
    plugin.yml
    Code (YAML):
    name: Surprise
    version
    : ${project.version}
    main
    : me.bhz.surprise.surprise.Surprise
    api-version
    : 1.13
    authors
    : [bhz_ema]
    description
    : Make a gift to everyone you want
    commands
    :
      surprise
    :
        description
    : Make a surprise to someone in your server
        usage
    : /surprise <player>
      permissions
    :
        surprise.admin
    :
          description
    : Allows you to use this plugin
          default
    : op

     
     
  2. Particle.REDSTONE is Particle.RED_DUST in 1.8
     
  3. Bio

    Bio

    So what should I do to make it work in 1.8?
    If i change it to RED_DUST i get an error
    @NoahvdAa
     
    #3 Bio, Aug 14, 2019
    Last edited: Aug 14, 2019
  4. Bio

    Bio

    • Friendly Friendly x 1
Thread Status:
Not open for further replies.