Team Plugin Hilfe

Dieses Thema im Forum "Programmierung" wurde erstellt von xSu, 9. Oktober 2012.

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. xSu
    Offline

    xSu

    Registriert seit:
    9. Oktober 2012
    Beiträge:
    10
    package de.xSu.TeamSystem;

    import java.util.Iterator;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;

    public class TeamCommand
    implements CommandExecutor
    {
    public TeamSystem plugin = TeamSystem.instance;

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    {
    String group;
    String member;
    if ((sender instanceof Player))
    {
    Player player = (Player)sender;
    if (player.hasPermission("TeamSystem.team"))
    {
    player.sendMessage(this.plugin.header.replace("&", "§"));
    for (Iterator localIterator1 = this.plugin.groups.iterator(); localIterator1.hasNext(); ) { group = (String)localIterator1.next();

    List members = this.plugin.getMember(group);
    if (members.size() == 0)
    {
    continue;
    }
    String msg = this.plugin.getGroupColor(group) + ": ";
    Boolean first = Boolean.valueOf(true);
    for (Iterator localIterator2 = members.iterator(); localIterator2.hasNext(); ) { member = (String)localIterator2.next();

    if (first.booleanValue())
    {
    msg = msg + this.plugin.colorplayername(member);
    first = Boolean.valueOf(false);
    }
    else
    {
    msg = msg + this.plugin.semicolon + this.plugin.colorplayername(member);
    }
    }
    player.sendMessage(msg.replace("&", "§"));
    }
    player.sendMessage(this.plugin.footer.replace("&", "§"));
    return true;
    }

    player.sendMessage(ChatColor.RED + "No permissions!");
    return true;
    }

    Bukkit.getConsoleSender().sendMessage(this.plugin.header.replace("&", "§"));
    for (String group1 : this.plugin.groups)
    {
    List members = this.plugin.getMember(group1);
    if (members.size() == 0)
    {
    continue;
    }
    String msg = this.plugin.getGroupColor(group1) + ": ";
    Boolean first = Boolean.valueOf(true);
    for (String member1 : members)
    {
    if (first.booleanValue())
    {
    msg = msg + this.plugin.colorplayername(member1);
    first = Boolean.valueOf(false);
    }
    else
    {
    msg = msg + this.plugin.semicolon + this.plugin.colorplayername(member1);
    }
    }
    Bukkit.getConsoleSender().sendMessage(msg.replace("&", "§"));
    }
    Bukkit.getConsoleSender().sendMessage(this.plugin.footer.replace("&", "§"));
    return true;
    }
    }

    for (String group : this.plugin.groups)
    das: this.plugin.groups <- ist Rot unterstrichen, ich komme da irgend wie nicht weiter, also weiss nicht weiter.

    for (String member1 : members)
    das: members <- ist Rot unterstrichen, da komme ich garnicht weiter..

    Kann mir vllt. jemand helfen?
     
    #1
  2. ~Desert-Gaming~
    Offline

    ~Desert-Gaming~

    Registriert seit:
    8. Oktober 2012
    Beiträge:
    35
    Ort:
    Baden-Württemberg
    ..Was willst du denn erreichen?
    ..Welches Plugin ist es? (Wird wohl nicht "Team-Plugin" heißen, oder? o_O)
     
    #2
  3. xSu
    Offline

    xSu

    Registriert seit:
    9. Oktober 2012
    Beiträge:
    10
    MainClass
    package me.xSu.TeamSystem;

    import java.io.PrintStream;
    import java.util.ArrayList;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.command.PluginCommand;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.FileConfigurationOptions;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import ru.tehkode.permissions.PermissionGroup;
    import ru.tehkode.permissions.PermissionManager;
    import ru.tehkode.permissions.PermissionUser;
    import ru.tehkode.permissions.bukkit.PermissionsEx;

    public class TeamSystem extends JavaPlugin
    {
    public String header;
    public String footer;
    public String semicolon;
    public String coloroffline;
    public String coloronline;
    public List<String> groups;
    public static TeamSystem instance;

    public void onDisable()
    {
    System.out.println("[TeamSystem] v. 1.0 disabled!");
    }

    public void onEnable()
    {
    instance = this;
    loadConfig();
    getCommand("team").setExecutor(new TeamCommand());
    System.out.println("[TeamSystem] v. 1.0 enabled!");
    }

    public List<String> getMember(String group)
    {
    PermissionUser[] users = PermissionsEx.getPermissionManager().getGroup(group).getUsers();
    List member = new ArrayList();
    for (PermissionUser pu : users)
    {
    member.add(pu.getName());
    }

    return member;
    }

    public void loadConfig()
    {
    getConfig().options().copyDefaults(true);
    getConfig().addDefault("header", "&b[]---------- &6Teammember&b ----------[]");
    getConfig().addDefault("footer", "&b[]-------------------------------[]");
    getConfig().addDefault("colorOffline", "&7");
    getConfig().addDefault("colorOnline", "&c");
    getConfig().addDefault("Semicolon", " &b¦ ");
    List groups = new ArrayList();
    groups.add("Owner");
    groups.add("Scripter");
    groups.add("Gamemaster");
    groups.add("CommunityManager");
    groups.add("Supporter");
    groups.add("ChatSupporter");
    getConfig().addDefault("Groups", groups);
    this.header = getConfig().getString("header");
    this.footer = getConfig().getString("footer");
    this.semicolon = getConfig().getString("Semicolon");
    this.coloronline = getConfig().getString("colorOnline");
    this.coloroffline = getConfig().getString("colorOffline");
    this.groups = getConfig().getList("Groups");
    saveConfig();
    }

    public String colorplayername(String playername)
    {
    try
    {
    Player player = Bukkit.getPlayer(playername);
    if (player.isOnline())
    {
    return this.coloronline + playername;
    }

    return this.coloroffline + playername;
    }
    catch (Exception e) {
    }
    return this.coloroffline + playername;
    }

    public String getGroupColor(String group)
    {
    try
    {
    String prefix = PermissionsEx.getPermissionManager().getGroup(group).getPrefix();
    if (prefix.length() > 2)
    {
    prefix = prefix.substring(0, 2);
    }
    return prefix + group;
    } catch (Exception e) {
    }
    return group;
    }
    }

    CommandClass
    package me.xSu.TeamSystem;

    import java.util.Iterator;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;

    public class TeamCommand
    implements CommandExecutor
    {
    public TeamSystem plugin = TeamSystem.instance;

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    {
    String group;
    String member;
    if ((sender instanceof Player))
    {
    Player player = (Player)sender;
    if (player.hasPermission("TeamSystem.team"))
    {
    player.sendMessage(this.plugin.header.replace("&", "§"));
    for (Iterator localIterator1 = this.plugin.groups.iterator(); localIterator1.hasNext(); ) { group = (String)localIterator1.next();

    List members = this.plugin.getMember(group);
    if (members.size() == 0)
    {
    continue;
    }
    String msg = this.plugin.getGroupColor(group) + ": ";
    Boolean first = Boolean.valueOf(true);
    for (Iterator localIterator2 = members.iterator(); localIterator2.hasNext(); ) { member = (String)localIterator2.next();

    if (first.booleanValue())
    {
    msg = msg + this.plugin.colorplayername(member);
    first = Boolean.valueOf(false);
    }
    else
    {
    msg = msg + this.plugin.semicolon + this.plugin.colorplayername(member);
    }
    }
    player.sendMessage(msg.replace("&", "§"));
    }
    player.sendMessage(this.plugin.footer.replace("&", "§"));
    return true;
    }

    player.sendMessage(ChatColor.RED + "No permissions!");
    return true;
    }

    Bukkit.getConsoleSender().sendMessage(this.plugin.header.replace("&", "§"));
    for (String group : this.plugin.groups)
    {
    List members = this.plugin.getMember(group);
    if (members.size() == 0)
    {
    continue;
    }
    String msg = this.plugin.getGroupColor(group) + ": ";
    Boolean first = Boolean.valueOf(true);
    for (String member : members)
    {
    if (first.booleanValue())
    {
    msg = msg + this.plugin.colorplayername(member);
    first = Boolean.valueOf(false);
    }
    else
    {
    msg = msg + this.plugin.semicolon + this.plugin.colorplayername(member);
    }
    }
    Bukkit.getConsoleSender().sendMessage(msg.replace("&", "§"));
    }
    Bukkit.getConsoleSender().sendMessage(this.plugin.footer.replace("&", "§"));
    return true;
    }
    }

    Nur jetzt sind die beiden meine Probleme:

    for (String group : this.plugin.groups) das: this.plugin.groups <- ist Rot unterstrichen, ich komme da irgend wie nicht weiter, also weiss nicht weiter.

    for (String member1 : members) das: members <- ist Rot unterstrichen, da komme ich garnicht weiter..
     
    #3
  4. xapfeltortexp
    Offline

    xapfeltortexp

    Registriert seit:
    27. Januar 2012
    Beiträge:
    163
    du bestimmst ja auch memer1 und group als string . also arbeite auch damit
     
    #4
  5. Let's Mine
    Offline

    Let's Mine Ehem. Teammitglied

    Registriert seit:
    1. Dezember 2011
    Beiträge:
    421
    Ort:
    Let's Mine
    Minecraft:
    LetsMine
    Hast du den Code einfach irgendwo rauskopiert ? o_O
     
    #5
  6. xSu
    Offline

    xSu

    Registriert seit:
    9. Oktober 2012
    Beiträge:
    10
    Könnte ich dir den richtigen Code mal Schicken per PN ?
     
    #6
  7. Lik3Fr33
    Offline

    Lik3Fr33 Gesperrt

    Registriert seit:
    1. Oktober 2012
    Beiträge:
    37
    Minecraft:
    mdafcker / Lik3Fr33
    Kannste mir Bitte auch den richtigen Code schiken per PN? :)

    LG; Lik3Fr33
     
    #7
  8. viebi
    Offline

    viebi

    Registriert seit:
    8. Oktober 2012
    Beiträge:
    6
    Sieht wirklich so aus, als hättest du es irgendwo kopiert und nur das Package umbenannt. Ansonsten würdest du schnell zur Lösung kommen, auch mit nur ein wenig Ahnung davon, denn die meisten IDE's geben Lösungvorschläge vor, wenn sie was an dem COde zu bemängeln haben.

    MfG
     
    #8
Status des Themas:
Es sind keine weiteren Antworten möglich.