示例#1
0
  @SuppressWarnings("static-access")
  public void onPlayerJoin(PlayerJoinEvent event) {

    Player player = event.getPlayer();
    plugin.Tools.checkAccount(player);
    if (plugin.SpoutEnabled && plugin.EnableSkillMastery && plugin.EnableCapes) {
      SpoutPlayer sp = (SpoutPlayer) event.getPlayer();
      File CapeFile = new File(plugin.getDataFolder() + "/Data/Cape.data");
      if (plugin.FlatFile.contains(sp.getName(), CapeFile)) {
        AppearanceManager appearM = SpoutManager.getAppearanceManager();
        appearM.setGlobalCloak(
            sp,
            "http://cloud.github.com/downloads/samkio/Levelcraft/"
                + plugin.FlatFile.getString(sp.getName(), CapeFile)
                + ".png");
        return;
      }
      for (Plugin plug : plugin.LevelNames.keySet()) {
        if (!plugin.Permissions.hasLevel(player, plug)) continue;
        if (!(plugin.LevelFunctions.getLevel(player, plug) >= plugin.LevelCap)) continue;
        AppearanceManager appearM = SpoutManager.getAppearanceManager();
        appearM.setGlobalCloak(
            sp,
            "http://cloud.github.com/downloads/samkio/Levelcraft/"
                + plugin.LevelNames.get(plug)
                + ".png");
        return;
      }
    }
  }
 @EventHandler
 public void onButtonClick(ButtonClickEvent event) {
   TreeTabButton button = (TreeTabButton) event.getButton();
   SpoutPlayer sPlayer = event.getPlayer();
   sPlayer.sendMessage("Button " + button.getSkillSet().toString() + " clicked");
   gui.switchSkillTreeTab(button, sPlayer);
 }
 @Override
 public void keyPressed(KeyBindingEvent keyBindingEvent) {
   Keyboard key = keyBindingEvent.getBinding().getDefaultKey();
   switch (key) {
     case KEY_1:
     case KEY_2:
     case KEY_3:
     case KEY_4:
     case KEY_5:
     case KEY_6:
     case KEY_7:
     case KEY_8:
     case KEY_9:
       SpoutPlayer p = keyBindingEvent.getPlayer();
       if (holdingCtrl.contains(p)) {
         int numKey = (int) key.toString().charAt(4) - 49;
         p.sendMessage(numKey + " pressed");
         // p.setItemInHand( lastWep.get( p ) ); // This is wrong. This puts the pressed keys
         // item in the current hand. It doesn't change the #slot that's active..
         SkillsPlayer mmoPlayer = MMOSkillTree.mmoPlayerManager.get(p);
         mmoPlayer.activateSkill(numKey);
       }
       break;
   }
   if (key == Keyboard.KEY_LCONTROL) {
     SpoutPlayer p = keyBindingEvent.getPlayer();
     holdingCtrl.add(p);
     lastWep.put(p, p.getItemInHand());
   }
 }
示例#4
0
  public Banker spawnBanker(String name, Location l, String id, String bankName) {
    if (bankers.containsKey(id)) {
      Log.warning("NPC with that id already exists, existing NPC returned");
      return bankers.get(id);
    } else {
      if (name.length()
          > 16) { // Check and nag if name is too long, spawn NPC anyway with shortened name.
        String tmp = name.substring(0, 16);
        Log.warning("NPCs can't have names longer than 16 characters,");
        Log.warning(name + " has been shortened to " + tmp);
        name = tmp;
      }
      WorldServer ws = getWorldServer(l.getWorld());
      NPCEntity npcEntity = new NPCEntity(this, ws, name, new ItemInWorldManager(ws));
      npcEntity.setPositionRotation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
      ws.addEntity(npcEntity); // the right way
      Banker npc = new Banker(npcEntity, bankName);
      npc.setYaw(l.getYaw());

      if (Bukkit.getPluginManager().isPluginEnabled("Spout")) {
        SpoutPlayer sp = npc.getSpoutPlayer();
        sp.setSkin("http://dl.dropbox.com/u/18216599/images/bankersskin.png");
        sp.setTitle(ChatColor.GOLD + "Banker\n" + ChatColor.WHITE + "[" + bankName + "]");
      }

      bankers.put(id, npc);
      return npc;
    }
  }
示例#5
0
 /**
  * Resets the player's selected NPC's cape. A valid NPC must be a generic HumanEntity only.
  *
  * @param player
  */
 public void removeCape(NPC npc) {
   LivingEntity entity = npc.getBukkitEntity();
   if (entity instanceof HumanEntity) {
     SpoutPlayer human = NpcManager.toSpoutPlayer(npc);
     human.resetCape();
     saveCape(npc, "default");
   }
 }
示例#6
0
 /**
  * Changes the player's selected NPC's cape. A valid NPC must be a generic HumanEntity only.
  *
  * @param player
  * @param url
  */
 public void applyCape(NPC npc, String url) {
   LivingEntity entity = npc.getBukkitEntity();
   if (entity instanceof HumanEntity) {
     SpoutPlayer human = NpcManager.toSpoutPlayer(npc);
     human.setCape(url);
     saveCape(npc, url);
   }
 }
示例#7
0
 /**
  * Sets the entity skin for the target entity to the url. The Skin Type is used when an entity has
  * more than one skin type.
  *
  * @param target to set the skin on
  * @param url of the skin
  * @param type of skin to set
  */
 public void setEntitySkin(LivingEntity target, String url, EntitySkinType type) {
   SpoutManager.getPlayerChunkMap().getGlobalInfo().setEntitySkin(target, url, type);
   ArrayList<LivingEntity> entities = new ArrayList<LivingEntity>(1);
   entities.add(target);
   for (SpoutPlayer player : getOnlinePlayers()) {
     player.updateEntitySkins(entities);
   }
 }
 @Override
 public void a(Packet10Flying packet) {
   manageChunkQueue(true);
   SpoutPlayer player = SpoutManager.getPlayer(this.getPlayer());
   boolean old = ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight;
   ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight = player.canFly();
   super.a(packet);
   ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight = old;
 }
示例#9
0
 public boolean setSkin(final String url) {
   try {
     Class.forName("org.getspout.spout.Spout");
     final SpoutPlayer sp = this.getSpoutPlayer();
     sp.setSkin(url);
     return true;
   } catch (final ClassNotFoundException e) {
     return false;
   }
 }
  @Override
  public void onButtonClick(Button button) {

    if (button.equals(button1)) {
      spoutp.getMainScreen().getActivePopup().close();
      spoutp.getMainScreen().attachPopupScreen(new PrimClassesGUI(plugin, spoutp));
    } else if (button.equals(button2)) {
      spoutp.getMainScreen().getActivePopup().close();
      spoutp.getMainScreen().attachPopupScreen(new ProfClassesGUI(plugin, spoutp));
    }
  }
示例#11
0
 public void setTitle(LivingEntity entity, String title) {
   if (entity instanceof SpoutPlayer) {
     ((SpoutPlayer) entity).setTitle(title);
   }
   titles.put(entity.getEntityId(), title);
   ArrayList<LivingEntity> entities = new ArrayList<LivingEntity>(1);
   entities.add(entity);
   for (SpoutPlayer player : getOnlinePlayers()) {
     player.updateEntitySkins(entities);
   }
 }
示例#12
0
  public void updateOwnerList(FPlayer player) {
    SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer());
    if (!sPlayer.isSpoutCraftEnabled()
        || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow)) return;

    FLocation here = player.getLastStoodAt();
    Faction factionHere = Board.getFactionAt(here);

    doOwnerList(player, sPlayer, here, factionHere);

    return;
  }
  public void setPlayerChunk(int cx, int cz) {
    ChunkCoordIntPair cur = currentChunk.get();
    if (cur.x != cx || cur.z != cz) {
      currentChunk.set(new ChunkCoordIntPair(cx, cz));
      updateCounter.incrementAndGet();

      SpoutPlayer player = (SpoutPlayer) getPlayer();
      if (player != null && player.isSpoutCraftEnabled()) {
        Spout.getInstance().getPlayerTrackingManager().onMoveChunk((SpoutPlayer) getPlayer());
      }
    }
  }
示例#14
0
  public boolean updateTerritoryDisplay(FPlayer player, boolean notify) {
    Player p = player.getPlayer();
    if (p == null) return false;

    SpoutPlayer sPlayer = SpoutManager.getPlayer(p);
    if (!sPlayer.isSpoutCraftEnabled()
        || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow)) return false;

    doLabels(player, sPlayer, notify);

    return true;
  }
  public void onActivation(Location location, SpoutPlayer player) {
    // Setting player health
    if (player.getHealth() == 20) return;
    if (player.getHealth() >= 15) player.setHealth(20);
    else player.setHealth(player.getHealth() + 5);

    // Playing red drip particles on player location
    Location loc = player.getLocation();
    Particle healParticle = new Particle(ParticleType.DRIPWATER, loc, new Vector(0.5D, 3.0D, 0.5D));
    healParticle.setParticleBlue(0.0F).setParticleGreen(0.0F).setParticleRed(1.0F);
    healParticle.setMaxAge(40).setAmount(15).setGravity(1.1F);
    healParticle.spawn();
  }
 private void updateBlockAttributes(int id, short data) {
   org.getspout.spoutapi.material.Block block = MaterialData.getBlock(id, data);
   if (block != null) {
     cachedBlockData = null;
     HashSet<org.getspout.spoutapi.material.Block> toUpdate =
         new HashSet<org.getspout.spoutapi.material.Block>(1);
     toUpdate.add(block);
     SpoutPacket updatePacket = new PacketBlockData(toUpdate);
     for (SpoutPlayer player : SpoutManager.getOnlinePlayers()) {
       if (player.isSpoutCraftEnabled()) player.sendPacket(updatePacket);
     }
   }
 }
示例#17
0
 @Override
 public void stopMusic(Location location) {
   /** get players in radius of the jukebox and start it for only those players * */
   for (Player p : location.getWorld().getPlayers()) {
     double distance = location.toVector().distance(p.getLocation().toVector());
     if (distance <= (double) range) {
       SpoutPlayer sp = SpoutManager.getPlayer(p);
       if (sp.isSpoutCraftEnabled()) {
         SpoutManager.getSoundManager().stopMusic(sp);
       }
     }
   }
 }
示例#18
0
 @Override
 public void onTick() {
   SpoutPlayer player = (SpoutPlayer) SpoutManager.getPlayerFromId(playerId);
   if (player != null && player.getVersion() > 17) {
     if (getActivePopup() != null) {
       if (getActivePopup().isDirty()) {
         player.sendPacket(new PacketWidget(getActivePopup(), getId()));
         getActivePopup().setDirty(false);
       }
       getActivePopup().onTick();
     }
   }
   super.onTick();
 }
示例#19
0
 public boolean closePopup() {
   if (getActivePopup() == null) {
     return false;
   }
   SpoutPlayer player = SpoutManager.getPlayerFromId(playerId);
   ScreenCloseEvent event = new ScreenCloseEvent(player, getActivePopup());
   Bukkit.getServer().getPluginManager().callEvent(event);
   if (event.isCancelled()) {
     return false;
   }
   player.sendPacket(new PacketScreenAction(ScreenAction.ScreenClose));
   activePopup = null;
   return true;
 }
示例#20
0
 public GenericCustomItem(Plugin plugin, String name) {
   super(
       name,
       318,
       mm.registerCustomItemName(plugin, plugin.getDescription().getName() + "." + name));
   this.fullName = plugin.getDescription().getName() + "." + name;
   this.customId = mm.registerCustomItemName(plugin, fullName);
   this.plugin = plugin;
   this.setName(name);
   MaterialData.addCustomItem(this);
   for (SpoutPlayer player : Spout.getServer().getOnlinePlayers()) {
     player.sendPacket(this);
   }
 }
 private void handleScreenCloseCancelled(SpoutPlayer player, ScreenCloseEvent e, boolean update) {
   this.action = (byte) ScreenAction.Close.getId();
   PopupScreen screen = player.getMainScreen().getActivePopup();
   if (screen != null) {
     if (update) {
       screen.onScreenClose(e);
     }
     if (!e.isCancelled() && ScreenType.getType(this.screen) == ScreenType.CUSTOM_SCREEN) {
       handleScreenClose(player, e, false);
       return;
     }
     screen.setDirty(true);
     player.sendImmediatePacket(new PacketWidget(screen, screen.getId()));
   }
 }
 private void handleScreenClose(SpoutPlayer player, ScreenCloseEvent e, boolean update) {
   PopupScreen p = player.getMainScreen().getActivePopup();
   if (update && p != null) {
     p.onScreenClose(e);
   }
   if (e.isCancelled()) {
     handleScreenCloseCancelled(player, e, false);
     return;
   }
   player.getMainScreen().closePopup();
   if (player.getItemOnCursor() != null && p != null) {
     p.handleItemOnCursor(player.getItemOnCursor());
     player.setItemOnCursor(null);
   }
 }
 @Override
 public void onTick() {
   SpoutPlayer player = (SpoutPlayer) SpoutManager.getPlayerFromId(playerId);
   if (player != null && player.isSpoutCraftEnabled()) {
     if (getActivePopup() != null) {
       if (getActivePopup().isDirty()) {
         if (!getActivePopup().getType().isServerOnly()) {
           player.sendPacket(new PacketWidget(getActivePopup(), getId()));
         }
         getActivePopup().setDirty(false);
       }
       getActivePopup().onTick();
     }
   }
   super.onTick();
 }
示例#24
0
  private void doOwnerList(
      FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) {
    // ----------
    // Owner list
    // ----------
    if (Conf.spoutTerritoryDisplayPosition > 0
        && Conf.spoutTerritoryDisplaySize > 0
        && Conf.spoutTerritoryOwnersShow
        && Conf.ownedAreasEnabled) {
      GenericLabel label;
      if (ownerLabels.containsKey(player.getName())) label = ownerLabels.get(player.getName());
      else {
        label = new GenericLabel();
        label
            .setWidth(1)
            .setHeight(1); // prevent Spout's questionable new "no default size" warning
        label.setScale(Conf.spoutTerritoryDisplaySize);
        label.setY((int) (10 * Conf.spoutTerritoryDisplaySize));
        sPlayer.getMainScreen().attachWidget(P.p, label);
        ownerLabels.put(player.getName(), label);
      }

      String msg = "";

      if (player.getFaction() == factionHere) {
        msg = factionHere.getOwnerListString(here);

        if (!msg.isEmpty()) msg = Conf.ownedLandMessage + msg;
      }

      label.setText(msg);
      alignLabel(label, msg);
      label.setDirty(true);
    }
  }
 @Override
 public boolean closePopup() {
   if (getActivePopup() == null) {
     return false;
   }
   SpoutPlayer player = SpoutManager.getPlayerFromId(playerId);
   ScreenCloseEvent event =
       new ScreenCloseEvent(player, getActivePopup(), ScreenType.CUSTOM_SCREEN);
   Bukkit.getServer().getPluginManager().callEvent(event);
   if (event.isCancelled()) {
     return false;
   }
   player.sendPacket(new PacketScreenAction(ScreenAction.Close, ScreenType.CUSTOM_SCREEN));
   activePopup = null;
   player.openScreen(ScreenType.GAME_SCREEN, false);
   return true;
 }
示例#26
0
 private static boolean hasRequiredBolt(SpoutPlayer player, String bolt) {
   for (ItemStack item : player.getInventory().getContents()) {
     /*if(item.getDurability() == MaterialManager.custombolts.get(bolt).getCustomId()){
     	return true;
     }*/
   }
   return false;
 }
示例#27
0
 public void onPlayerJoin(SpoutPlayer player) {
   if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
     for (TLongObjectIterator it = customNames.iterator(); it.hasNext(); ) {
       it.advance();
       ((SpoutPlayer) player)
           .sendPacket(
               new PacketItemName(msw(it.key()), (short) lsw(it.key()), (String) it.value()));
     }
     for (TLongObjectIterator it = customTextures.iterator(); it.hasNext(); ) {
       it.advance();
       String pluginName = (String) customTexturesPlugin.get(it.key());
       ((SpoutPlayer) player)
           .sendPacket(
               new PacketItemTexture(
                   msw(it.key()), (short) lsw(it.key()), pluginName, (String) it.value()));
     }
   }
 }
示例#28
0
 public static String getCrossbow(SpoutPlayer player) {
   ItemStack inHand = player.getItemInHand();
   /*for(GenericCustomTool crossbow :MaterialManager.customcrossbows){
   	if(inHand.getDurability() == crossbow.getCustomId()){
   		return crossbow.getName();
   	}
   }*/
   return null;
 }
示例#29
0
  private void tossItem(ItemStack dropItem) {
    Location loc = player.getLocation();
    loc.setY(loc.getY() + 1);

    Item item = loc.getWorld().dropItem(loc, dropItem);
    Vector v = loc.getDirection().multiply(0.2);
    v.setY(0.2);
    item.setVelocity(v);
  }
  public HeroesSelectGUI(HeroesHUD plugin, SpoutPlayer spoutp) {
    this.plugin = plugin;
    this.spoutp = spoutp;

    GenericTexture backgroundMain = new GenericTexture();

    int screenWidth = spoutp.getMainScreen().getWidth();
    int screenHeight = spoutp.getMainScreen().getHeight();
    int x = (screenWidth / 2) - 170;
    int y = (screenHeight / 2) - 100;

    // BackgroundMain!

    backgroundMain.setX(x).setY(y);
    backgroundMain.setWidth(340).setHeight(200);
    backgroundMain.setUrl(plugin.HeroesSelectGuiBackgroundMain);
    backgroundMain.setFixed(false);
    backgroundMain.setPriority(RenderPriority.Highest);

    // Button1 Main
    button1 = new GenericButton();
    button1.setText("Primary");
    button1
        .setWidth(GenericLabel.getStringWidth(button1.getText()) + 5 + 30)
        .setHeight(GenericLabel.getStringHeight(button1.getText()) + 5);
    button1.setX(backgroundMain.getX() + 20);
    button1.setY(backgroundMain.getY() + 65);
    button1.setDirty(true);
    button1.setAutoDirty(true);

    // Button2 Main
    button2 = new GenericButton();
    button2.setText("Profession");
    button2
        .setWidth(GenericLabel.getStringWidth(button2.getText()) + 5 + 30)
        .setHeight(GenericLabel.getStringHeight(button2.getText()) + 5);
    button2.setX(backgroundMain.getX() + 235);
    button2.setY(backgroundMain.getY() + 65);
    button2.setDirty(true);
    button2.setAutoDirty(true);

    super.attachWidgets(plugin, backgroundMain, button1, button2);
    super.setAnchor(WidgetAnchor.TOP_LEFT);
  }