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

[Inne] Java Bukkit plugin- Problemy z pisaniem pluginów? Pisz!


Rekomendowane odpowiedzi

Opublikowano

po prostu nie usuwasz gracza kompletnie gracza z pamięci podczas wylogwania?

Tak by był dalej uznany jako zlogowany, i podczas logowania sprawdzasz czy juz jest zalogowany czy nie

 

Nie o to mi chodzi. To może inaczej: Jak zrobić komendę którą można wykonać tylko raz aż do ponownego zalogowania. Proszę o jakiś kod na coś co by działało jak "zmienna globalna" ale globalna dla  pluginu. 

  • Odpowiedzi 52
  • Dodano
  • Ostatniej odpowiedzi
Opublikowano

Nie o to mi chodzi. To może inaczej: Jak zrobić komendę którą można wykonać tylko raz aż do ponownego zalogowania. Proszę o jakiś kod na coś co by działało jak "zmienna globalna" ale globalna dla  pluginu. 

Zrób globalną i statyczną listę nicków. Dodajesz tam nicki które nie moga już używac komendy, i sprawdzasz podczas komendy czy gracz znajduje się na tej liście.

I usuwasz z listy kiedy potrzebujesz.

 

Najlepiej użyc Set/TreeSet zamiast listy, bo Set nie może mieć duplikatów :P 

To już jest koniec smerfa:


http://www.mpcforum.pl/topic/1323530-info-znikam/


GG: 48522543


PS: Na innych forach i stronach znajdziesz mnie pod nickiem: 


BukkitSmerf

Opublikowano

jak zrobić taki o to scoreboard podczas gry xD

http://screenshooter.net/1671729/fpghefj

próbowałem już niestety cały się sypał

tak wygląda kod podczas gry xD

/*     */ package vc.pvp.skywars.player;
/*     */ 
/*     */ import net.milkbowl.vault.economy.Economy;
/*     */ import org.bukkit.entity.Player;
/*     */ import org.bukkit.inventory.ItemStack;
/*     */ import org.bukkit.inventory.PlayerInventory;
/*     */ import vc.pvp.skywars.SkyWars;
/*     */ import vc.pvp.skywars.config.PluginConfig;
/*     */ import vc.pvp.skywars.game.Game;
/*     */ import vc.pvp.skywars.storage.DataStorage;
/*     */ 
/*     */ public class GamePlayer
/*     */ {
/*     */   private final Player bukkitPlayer;
/*     */   private final String playerName;
/*     */   private Game game;
/*     */   private boolean chosenKit;
/*     */   private int score;
/*     */   private int gamesPlayed;
/*     */   private int gamesWon;
/*     */   private int kills;
/*     */   private int deaths;
/*     */   private boolean skipFallDamage;
/*     */   private boolean skipFireTicks;
/*  23 */   private ItemStack[] savedInventoryContents = null;
/*  24 */   private ItemStack[] savedArmorContents = null;
/*     */ 
/*     */   public GamePlayer(Player bukkitPlayer) {
/*  27 */     this.bukkitPlayer = bukkitPlayer;
/*  28 */     this.playerName = bukkitPlayer.getName();
/*     */ 
/*  30 */     DataStorage.get().loadPlayer(this);
/*     */   }
/*     */ 
/*     */   public GamePlayer(String playerName) {
/*  34 */     this.bukkitPlayer = null;
/*  35 */     this.playerName = playerName;
/*  36 */     DataStorage.get().loadPlayer(this);
/*     */   }
/*     */ 
/*     */   public void save() {
/*  40 */     DataStorage.get().savePlayer(this);
/*     */   }
/*     */ 
/*     */   public Player getBukkitPlayer() {
/*  44 */     return this.bukkitPlayer;
/*     */   }
/*     */ 
/*     */   public boolean isPlaying() {
/*  48 */     return this.game != null;
/*     */   }
/*     */ 
/*     */   public void setGame(Game game) {
/*  52 */     this.game = game;
/*     */   }
/*     */ 
/*     */   public Game getGame() {
/*  56 */     return this.game;
/*     */   }
/*     */ 
/*     */   public boolean hasChosenKit() {
/*  60 */     return this.chosenKit;
/*     */   }
/*     */ 
/*     */   public void setChosenKit(boolean yes) {
/*  64 */     this.chosenKit = yes;
/*     */   }
/*     */ 
/*     */   public int getScore() {
/*  68 */     if ((PluginConfig.useEconomy()) && (SkyWars.getEconomy() != null)) {
/*  69 */       return (int)SkyWars.getEconomy().getBalance(this.playerName);
/*     */     }
/*     */ 
/*  72 */     return this.score;
/*     */   }
/*     */ 
/*     */   public void setScore(int score) {
/*  76 */     if ((PluginConfig.useEconomy()) && (SkyWars.getEconomy() != null)) {
/*  77 */       double balance = SkyWars.getEconomy().getBalance(this.playerName);
/*  78 */       if (balance < 0.0D)
/*  79 */         SkyWars.getEconomy().depositPlayer(this.playerName, -balance);
/*     */       else {
/*  81 */         SkyWars.getEconomy().withdrawPlayer(this.playerName, balance);
/*     */       }
/*  83 */       addScore(score);
/*     */     }
/*     */     else {
/*  86 */       this.score = score;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void addScore(int score) {
/*  91 */     if ((PluginConfig.useEconomy()) && (SkyWars.getEconomy() != null)) {
/*  92 */       if (score < 0)
/*  93 */         SkyWars.getEconomy().withdrawPlayer(this.playerName, -score);
/*     */       else {
/*  95 */         SkyWars.getEconomy().depositPlayer(this.playerName, score);
/*     */       }
/*     */     }
/*     */     else
/*  99 */       this.score += score;
/*     */   }
/*     */ 
/*     */   public String toString()
/*     */   {
/* 105 */     return this.playerName;
/*     */   }
/*     */ 
/*     */   public String getName() {
/* 109 */     return this.playerName;
/*     */   }
/*     */ 
/*     */   public int getGamesPlayed() {
/* 113 */     return this.gamesPlayed;
/*     */   }
/*     */ 
/*     */   public void setGamesPlayed(int gamesPlayed) {
/* 117 */     this.gamesPlayed = gamesPlayed;
/*     */   }
/*     */ 
/*     */   public int getGamesWon() {
/* 121 */     return this.gamesWon;
/*     */   }
/*     */ 
/*     */   public void setGamesWon(int gamesWon) {
/* 125 */     this.gamesWon = gamesWon;
/*     */   }
/*     */ 
/*     */   public int getKills() {
/* 129 */     return this.kills;
/*     */   }
/*     */ 
/*     */   public void setKills(int kills) {
/* 133 */     this.kills = kills;
/*     */   }
/*     */ 
/*     */   public int getDeaths() {
/* 137 */     return this.deaths;
/*     */   }
/*     */ 
/*     */   public void setDeaths(int deaths) {
/* 141 */     this.deaths = deaths;
/*     */   }
/*     */ 
/*     */   public void setSkipFallDamage(boolean skipFallDamage) {
/* 145 */     this.skipFallDamage = skipFallDamage;
/*     */   }
/*     */ 
/*     */   public void setSkipFireTicks(boolean skipFireTicks) {
/* 149 */     this.skipFireTicks = skipFireTicks;
/*     */   }
/*     */ 
/*     */   public boolean shouldSkipFallDamage() {
/* 153 */     return this.skipFallDamage;
/*     */   }
/*     */ 
/*     */   public boolean shouldSkipFireTicks() {
/* 157 */     return this.skipFireTicks;
/*     */   }
/*     */ 
/*     */   public void saveCurrentState() {
/* 161 */     this.savedArmorContents = ((ItemStack[])this.bukkitPlayer.getInventory().getArmorContents().clone());
/* 162 */     this.savedInventoryContents = ((ItemStack[])this.bukkitPlayer.getInventory().getContents().clone());
/*     */   }
/*     */ 
/*     */   public void restoreState()
/*     */   {
/* 167 */     boolean shouldUpdateInventory = false;
/*     */ 
/* 169 */     if (this.savedArmorContents != null) {
/* 170 */       this.bukkitPlayer.getInventory().setArmorContents(this.savedArmorContents);
/* 171 */       this.savedArmorContents = null;
/* 172 */       shouldUpdateInventory = true;
/*     */     }
/*     */ 
/* 175 */     if (this.savedInventoryContents != null) {
/* 176 */       this.bukkitPlayer.getInventory().setContents(this.savedInventoryContents);
/* 177 */       this.savedInventoryContents = null;
/* 178 */       shouldUpdateInventory = true;
/*     */     }
/*     */ 
/* 181 */     if (shouldUpdateInventory)
/* 182 */       this.bukkitPlayer.updateInventory();
/*     */   }
/*     */ }

Zarchiwizowany

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

×
×
  • Dodaj nową pozycję...