Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

FunnyGuilds zmiana rankingu


TeseuS

Rekomendowane odpowiedzi

Opublikowano

Witam, jak zrobic w funnyguilds aby po smierci tracilo sie 50% rankingu ktory dostaje osoba zabijajaca jaka clasa odpowiada za to i co trzeba w niej zmienic

  • Biter. zmienił(a) tytuł na FunnyGuilds zmiana rankingu
Opublikowano

No masz w tej klasie

 

        Double d = victim.getRank().getPoints() * (Settings.getInstance().rankPercent / 100);
        int points = d.intValue();

        victim.getRank().removePoints(points);
        victim.setLastAttacker(attacker);

        attacker.getRank().addKill();
        attacker.getRank().addPoints(points);
        attacker.setLastVictim(victim);

 

Rusz czasem głową ;-;

        Double d = victim.getRank().getPoints() * (Settings.getInstance().rankPercent / 100);
        int attackerPoints = d.intValue();
	int victimPoints = d.intValue()/2;

        victim.getRank().removePoints(victimPoints);
        victim.setLastAttacker(attacker);

        attacker.getRank().addKill();
        attacker.getRank().addPoints(attackerPoints);
        attacker.setLastVictim(victim);

 

I pozmieniać reszte zmiennych w tej klasie 

Opublikowano

@__AHA__Zrobilem tak jak kazales zmienilem wszystko w tej klasie, zrobilem nowy projekt dodalem jara pluginu oraz slinik wyexportowalem otowrzylem plugin winrarem wrzucilame klase tam gdzie potrzeba i nie dziala mi nwm o co chodzi masz ten plugin swiezy bez rankingu przerobionego 

FunnyGuilds-EDIT.jar

Opublikowano

No szkoda tylko, że nic nie zmieniłeś..

 


package net.dzikoysk.funnyguilds.listener;

import org.bukkit.event.EventHandler;
import org.bukkit.entity.Player;
import net.dzikoysk.funnyguilds.util.StringUtils;
import net.dzikoysk.funnyguilds.util.thread.IndependentThread;
import net.dzikoysk.funnyguilds.util.thread.ActionType;
import net.dzikoysk.funnyguilds.data.Settings;
import net.dzikoysk.funnyguilds.data.Messages;
import net.dzikoysk.funnyguilds.basic.User;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.Listener;

public class PlayerDeath implements Listener
{
    private static long attackerCooldown;
    public static long victimCooldown;
    
    static {
        PlayerDeath.attackerCooldown = 7200000L;
        PlayerDeath.victimCooldown = 7200000L;
    }
    
    @EventHandler
    public void onDeath(final PlayerDeathEvent event) {
        final Player v = event.getEntity();
        final Player a = event.getEntity().getKiller();
        final User victim = User.get(v);
        victim.getRank().addDeath();
        if (a == null) {
            return;
        }
        final User attacker = User.get(a);
        if (attacker.getLastVictim() != null && attacker.getLastVictim().equals(victim)) {
            if (attacker.getLastVictimTime() + PlayerDeath.attackerCooldown > System.currentTimeMillis()) {
                v.sendMessage(Messages.getInstance().getMessage("rankLastVictimV"));
                a.sendMessage(Messages.getInstance().getMessage("rankLastVictimA"));
                return;
            }
        }
        else if (victim.getLastAttacker() != null && victim.getLastAttacker().equals(attacker) && victim.getLastVictimTime() + PlayerDeath.victimCooldown > System.currentTimeMillis()) {
            v.sendMessage(Messages.getInstance().getMessage("rankLastAttackerV"));
            a.sendMessage(Messages.getInstance().getMessage("rankLastAttackerA"));
            return;
        }
        final Double d = victim.getRank().getPoints() * (Settings.getInstance().rankPercent / 100.0);
        final int points = (int)(Object)d;
        victim.getRank().removePoints(points);
        victim.setLastAttacker(attacker);
        attacker.getRank().addKill();
        attacker.getRank().addPoints(points);
        attacker.setLastVictim(victim);
        if (Settings.getInstance().mysql) {
            if (victim.hasGuild()) {
                IndependentThread.actions(ActionType.MYSQL_UPDATE_GUILD_POINTS, victim.getGuild());
            }
            if (attacker.hasGuild()) {
                IndependentThread.actions(ActionType.MYSQL_UPDATE_GUILD_POINTS, attacker.getGuild());
            }
            IndependentThread.actions(ActionType.MYSQL_UPDATE_USER_POINTS, victim);
            IndependentThread.actions(ActionType.MYSQL_UPDATE_USER_POINTS, attacker);
        }
        IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, victim);
        IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, attacker);
        IndependentThread.actions(ActionType.RANK_UPDATE_USER, victim);
        IndependentThread.action(ActionType.RANK_UPDATE_USER, attacker);
        String death = Messages.getInstance().getMessage("rankDeathMessage");
        death = StringUtils.replace(death, "{ATTACKER}", attacker.getName());
        death = StringUtils.replace(death, "{VICTIM}", victim.getName());
        death = StringUtils.replace(death, "{-}", Integer.toString(points));
        death = StringUtils.replace(death, "{+}", Integer.toString(points));
        death = StringUtils.replace(death, "{POINTS}", Integer.toString(victim.getRank().getPoints()));
        if (victim.hasGuild()) {
            death = StringUtils.replace(death, "{VTAG}", StringUtils.replace(Settings.getInstance().chatGuild, "{TAG}", victim.getGuild().getTag()));
        }
        if (attacker.hasGuild()) {
            death = StringUtils.replace(death, "{ATAG}", StringUtils.replace(Settings.getInstance().chatGuild, "{TAG}", attacker.getGuild().getTag()));
        }
        death = StringUtils.replace(death, "{VTAG}", "");
        death = StringUtils.replace(death, "{ATAG}", "");
        event.setDeathMessage(death);
    }
}

 

masz

import net.dzikoysk.funnyguilds.basic.User;
import net.dzikoysk.funnyguilds.data.Messages;
import net.dzikoysk.funnyguilds.data.Settings;
import net.dzikoysk.funnyguilds.util.StringUtils;
import net.dzikoysk.funnyguilds.util.thread.ActionType;
import net.dzikoysk.funnyguilds.util.thread.IndependentThread;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;

public class PlayerDeath implements Listener {

    private static long attackerCooldown = 7200000L;
    public static long victimCooldown = 7200000L;

    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        Player v = event.getEntity();
        Player a = event.getEntity().getKiller();

        User victim = User.get(v);
        victim.getRank().addDeath();

        if (a == null) {
            return;
        }
        User attacker = User.get(a);

        if (attacker.getLastVictim() != null && attacker.getLastVictim().equals(victim)) {
            if (attacker.getLastVictimTime() + attackerCooldown > System.currentTimeMillis()) {
                v.sendMessage(Messages.getInstance().getMessage("rankLastVictimV"));
                a.sendMessage(Messages.getInstance().getMessage("rankLastVictimA"));
                return;
            }
        }
        else if (victim.getLastAttacker() != null && victim.getLastAttacker().equals(attacker)) {
            if (victim.getLastVictimTime() + victimCooldown > System.currentTimeMillis()) {
                v.sendMessage(Messages.getInstance().getMessage("rankLastAttackerV"));
                a.sendMessage(Messages.getInstance().getMessage("rankLastAttackerA"));
                return;
            }
        }

        Double d = victim.getRank().getPoints() * (Settings.getInstance().rankPercent / 100);
        int attackerPoints = d.intValue();
        int victimPoints = d.intValue()/2;

        victim.getRank().removePoints(victimPoints);
        victim.setLastAttacker(attacker);

        attacker.getRank().addKill();
        attacker.getRank().addPoints(attackerPoints);
        attacker.setLastVictim(victim);

        if (Settings.getInstance().mysql) {
            if (victim.hasGuild()) {
                IndependentThread.actions(ActionType.MYSQL_UPDATE_GUILD_POINTS, victim.getGuild());
            }
            if (attacker.hasGuild()) {
                IndependentThread.actions(ActionType.MYSQL_UPDATE_GUILD_POINTS, attacker.getGuild());
            }
            IndependentThread.actions(ActionType.MYSQL_UPDATE_USER_POINTS, victim);
            IndependentThread.actions(ActionType.MYSQL_UPDATE_USER_POINTS, attacker);
        }

        IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, victim);
        IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, attacker);
        IndependentThread.actions(ActionType.RANK_UPDATE_USER, victim);
        IndependentThread.action(ActionType.RANK_UPDATE_USER, attacker);

        String death = Messages.getInstance().getMessage("rankDeathMessage");
        death = StringUtils.replace(death, "{ATTACKER}", attacker.getName());
        death = StringUtils.replace(death, "{VICTIM}", victim.getName());
        death = StringUtils.replace(death, "{-}", Integer.toString(victimPoints));
        death = StringUtils.replace(death, "{+}", Integer.toString(attackerPoints));
        death = StringUtils.replace(death, "{POINTS}", Integer.toString(victim.getRank().getPoints()));
        if (victim.hasGuild()) {
            death = StringUtils.replace(death, "{VTAG}",
                    StringUtils.replace(Settings.getInstance().chatGuild, "{TAG}", victim.getGuild().getTag()));
        }
        if (attacker.hasGuild()) {
            death = StringUtils.replace(death, "{ATAG}",
                    StringUtils.replace(Settings.getInstance().chatGuild, "{TAG}", attacker.getGuild().getTag()));
        }
        death = StringUtils.replace(death, "{VTAG}", "");
        death = StringUtils.replace(death, "{ATAG}", "");
        event.setDeathMessage(death);
    }
}

 

Opublikowano

Dzienkuje, dziala. Wiesz jak naprawic aby tablista po odswiezaniu rankingu w topce nei zostawiala niechcianych zanaczkow oraz cyfer na tabie?

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...