Esempio n. 1
0
  public void a(DamageSource damagesource) {
    // CanaryMod: PlayerDeathHook
    PlayerDeathHook hook = new PlayerDeathHook(getPlayer(), this.bt.b());

    Canary.hooks().callHook(hook);

    // Check Death Message enabled
    if (Configuration.getServerConfig().isDeathMessageEnabled()) {
      this.b.ad().k(hook.getDeathMessage());
    }
    //

    if (!this.q.N().b("keepInventory")) {
      this.bK.m();
    }

    Collection collection = this.q.W().a(ScoreObjectiveCriteria.c);
    Iterator iterator = collection.iterator();

    while (iterator.hasNext()) {
      ScoreObjective scoreobjective = (ScoreObjective) iterator.next();
      Score score = this.cr().a(this.am(), scoreobjective);

      score.a();
    }

    EntityLiving entityliving = this.bN();

    if (entityliving != null) {
      entityliving.c(this, this.aM);
    }
  }
Esempio n. 2
0
  public boolean a(DamageSource damagesource, int i0) {
    if (this.aq()) {
      return false;
    } else {
      // CanaryMod moved pvp to per-world config
      boolean haspvp = Configuration.getWorldConfig(getCanaryWorld().getFqName()).isPvpEnabled();
      boolean flag0 = this.b.T() && haspvp && "fall".equals(damagesource.o);

      if (!flag0 && this.cq > 0 && damagesource != DamageSource.i) {
        return false;
      } else {
        if (damagesource instanceof EntityDamageSource) {
          Entity entity = damagesource.i();

          if (entity instanceof EntityPlayer && !this.a((EntityPlayer) entity)) {
            return false;
          }

          if (entity instanceof EntityArrow) {
            EntityArrow entityarrow = (EntityArrow) entity;

            if (entityarrow.c instanceof EntityPlayer && !this.a((EntityPlayer) entityarrow.c)) {
              return false;
            }
          }
        }

        return super.a(damagesource, i0);
      }
    }
  }
 public OServerConfigurationManager(OMinecraftServer var1) {
   // CanaryMod NOTE: Canary.setServer() has been called during construction of OMCS which is being
   // passed along here
   // Just for the records
   super();
   this.c = var1;
   // CanaryMod start: changing configurations
   // this.j = var1.a("banned-players.txt");
   // this.k = var1.a("banned-ips.txt");
   // this.l = var1.a("ops.txt");
   // this.m = var1.a("white-list.txt");
   // int var2 = Configuration.getNetConfig().getViewDistance();
   // Creates player managers per dimension (MW: create one per dimension per world)
   // this.d[0] = new OPlayerManager(var1, 0, var2);
   // this.d[1] = new OPlayerManager(var1, -1, var2);
   // this.d[2] = new OPlayerManager(var1, 1, var2);
   this.e = Configuration.getNetConfig().getMaxPlayers();
   // CanaryMod: disable vanilla whitelisting
   this.o = false;
   // CanaryMod: don't load the default whitelists and bans
   // this.l();
   // this.n();
   // this.loadOperatorList();
   // this.r();
   // this.m();
   // this.o();
   // this.q();
   // this.s();
   canaryCfgManager = new CanaryConfigurationManager(this);
   var1.setCanaryConfigurationmanager(canaryCfgManager);
 }
Esempio n. 4
0
 @Override
 public void enable() {
   this.log = Logger.getLogger("Minecraft");
   final File dir = new File("IRCanary");
   if (!dir.exists()) {
     dir.mkdir();
   }
   try {
     final ConfigurationFile ircProperties = Configuration.getPluginConfig("IRCanary");
     this.serverHost = ircProperties.getString("server-host", "localhost");
     this.serverPort = ircProperties.getInt("server-port", 6667);
     this.nickname = ircProperties.getString("bot-nickname", "aMinecraftBot");
     this.ircChannel = ircProperties.getString("irc-channel", "#minecraftbot");
     this.ircUserColor = ircProperties.getString("irc-usercolor", "f");
     this.ircNameSeparator = ircProperties.getString("irc-separator", "<,>").split(",");
     this.characterLimit = ircProperties.getInt("charlimit", 390);
     this.msgCommandRequired = ircProperties.getBoolean("msg-command-required", false);
     this.echoIRCMessages = ircProperties.getBoolean("repeat-relay-back", false);
     this.debugMode = ircProperties.getBoolean("debug-spam-mode", false);
     this.botAuthLine = ircProperties.getString("auth-message", "");
     this.commandPrefix = ircProperties.getString("irc-command-prefix", ".").charAt(0);
     this.allowJoinQuitUpdates = ircProperties.getBoolean("send-join-quit-to-IRC", true);
     this.allowKickBanUpdates = ircProperties.getBoolean("send-kick-ban-to-IRC", true);
     this.kickMessage =
         ircProperties.getString("kick-formatting", "%player kicked (\"%reason%\")");
     this.banMessage = ircProperties.getString("ban-formatting", "%player banned (\"%reason%\")");
   } catch (final Exception e) {
     this.log.log(Level.SEVERE, "[IRCanary] Exception while reading from irc.properties", e);
   }
   this.botEnabled = true;
   this.bot =
       new IRCBot(
           this.nickname,
           this.msgCommandRequired,
           this.characterLimit,
           this.ircUserColor,
           this.echoIRCMessages,
           this.ircNameSeparator,
           this,
           this.commandPrefix);
   if (this.debugMode) {
     this.bot.setVerbose(true);
   }
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.CHAT);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.COMMAND);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.LOGIN);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.PLAYER_DISCONNECT);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.KICK);
   Canary.hooks().registerListener(listener, this, Priority.NORMAL, Hook.Type.BAN);
   this.resetBot();
   this.loadAdmins();
   this.log.log(Level.INFO, "[IRCanary] Version " + this.version + " enabled!");
 }
  public BiomeGenBase[] a(BiomeGenBase[] abiomegenbase, int i0, int i1, int i2, int i3) {
    IntCache.a();
    if (abiomegenbase == null || abiomegenbase.length < i2 * i3) {
      abiomegenbase = new BiomeGenBase[i2 * i3];
    }

    int[] aint = this.d.a(i0, i1, i2, i3);

    for (int i4 = 0; i4 < i2 * i3; ++i4) {
      // CanaryMod: Biome disabling and replacements
      BiomeGenBase biomegenbase = BiomeGenBase.a[aint[i4]];
      if (Configuration.getWorldConfig(world_name).isBiomeDisabled(biomegenbase.N)) {
        String old = biomegenbase.y;
        biomegenbase =
            BiomeGenBase.a[
                Configuration.getWorldConfig(world_name).getReplacementBiomeId(biomegenbase.N)];
        Canary.logDebug("Biome: " + old + " is disabled and replaced with " + biomegenbase.y);
      }
      abiomegenbase[i4] = biomegenbase;
      //
    }

    return abiomegenbase;
  }
 @Override
 public void valueChanged(ListSelectionEvent e) {
   if ((playerBox.getSelectedValue() != null) && !isRunning) {
     Logman.getLogman("Box").info((String) playerBox.getSelectedValue());
     Player test = Canary.getServer().getPlayer((String) playerBox.getSelectedValue());
     if (test == null) {
       if (Configuration.getServerConfig().isDebugMode()) {
         Logman.getLogman("GUI").logDerp("Null Player from list!");
       }
     } else {
       Logman.getLogman("GUI").info(test.getName());
       playersettingsbox = new PlayerSettings(test);
     }
   }
 }
Esempio n. 7
0
  /**
   * Reload all subsystems and the whole of canary. Don't over-use this method, it slows down the
   * server. It is used by the reload command and should not be used by anything else!
   */
  public void reload() {

    // Reload configurations
    Configuration.reload();

    // Reload all subsystems with a cache
    instance.banManager.reload();
    instance.kitProvider.reload();
    instance.userAndGroupsProvider.reloadAll();
    instance.warpProvider.reload();
    instance.whitelist.reload();
    instance.reservelist.reload();
    instance.ops.reload();
    instance.motd.reload();

    // Reload Player permissions and groups data
    for (Player p : getServer().getPlayerList()) {
      userAndGroupsProvider.addOrUpdatePlayerData(p);
    }
  }
Esempio n. 8
0
  public EntityPlayerMP(
      MinecraftServer minecraftserver,
      World world,
      String s0,
      ItemInWorldManager iteminworldmanager) {
    super(world);
    WorldConfiguration cfg = Configuration.getWorldConfig(world.getCanaryWorld().getFqName());
    iteminworldmanager.b = this;
    this.c = iteminworldmanager;
    this.cr = minecraftserver.ad().o();
    ChunkCoordinates chunkcoordinates = world.J();
    int i0 = chunkcoordinates.a;
    int i1 = chunkcoordinates.c;
    int i2 = chunkcoordinates.b;

    if (!world.t.f && world.M().r() != EnumGameType.d) {
      int i3 = Math.max(5, cfg.getSpawnProtectionSize() - 6);

      i0 += this.ab.nextInt(i3 * 2) - i3;
      i1 += this.ab.nextInt(i3 * 2) - i3;
      i2 = world.i(i0, i1);
    }
    // TODO: Might be a good palce to put mode-switchign here (when going into other-mode worlds)
    this.b = minecraftserver;
    this.Y = 0.0F;
    this.bS = s0;
    this.N = 0.0F;
    this.b((double) i0 + 0.5D, (double) i2, (double) i1 + 0.5D, 0.0F, 0.0F);

    while (!world.a((Entity) this, this.E).isEmpty()) {
      this.b(this.u, this.v + 1.0D, this.w);
    }

    // CanaryMod: create wrapper
    if (!(this instanceof EntityNonPlayableCharacter)) { // We might be an NPC
      this.entity = new CanaryPlayer(this);
    }
    //
  }
Esempio n. 9
0
 public boolean a(EntityPlayer entityplayer) {
   // CanaryMod moved pvp to per-world config
   boolean haspvp = Configuration.getWorldConfig(getCanaryWorld().getFqName()).isPvpEnabled();
   return !haspvp ? false : super.a(entityplayer);
 }
Esempio n. 10
0
  public void g() {
    try {
      super.l_();

      for (int i0 = 0; i0 < this.bK.j_(); ++i0) {
        ItemStack itemstack = this.bK.a(i0);

        if (itemstack != null && Item.f[itemstack.c].f() && this.a.e() <= 5) {
          Packet packet = ((ItemMapBase) Item.f[itemstack.c]).c(itemstack, this.q, this);

          if (packet != null) {
            this.a.b(packet);
          }
        }
      }

      // CanaryMod: HealthChange / HealthEnabled
      if (this.aX() != this.cm && cm != -99999999 && this.getPlayer() != null) {
        // updates your health when it is changed.
        if (!Configuration.getWorldConfig(getCanaryWorld().getFqName()).isHealthEnabled()) {
          super.b(this.aW());
          this.M = false;
        } else {
          HealthChangeHook hook = new HealthChangeHook(getPlayer(), cm, this.aX());

          Canary.hooks().callHook(hook);
          if (hook.isCanceled()) {
            super.b(this.cm);
          }
        }
      }
      //

      if (this.aX() != this.cm || this.cn != this.bN.a() || this.bN.e() == 0.0F != this.co) {
        // CanaryMod: convert health for values above 20
        int health = (int) (this.aX() / (this.aW() / 20));

        health = (this.aX() > 0 && health == 0) ? 1 : health;
        this.a.b(new Packet8UpdateHealth(health, this.bN.a(), this.bN.e()));
        //
        this.cm = this.aX();
        this.cn = this.bN.a();
        this.co = this.bN.e() == 0.0F;
      }

      if (this.cg != this.cp) {
        // CanaryMod: ExperienceHook / ExperienceEnabled
        if (!Configuration.getWorldConfig(getCanaryWorld().getFqName()).isExperienceEnabled()) {
          this.cg = 0;
          this.cf = 0;
        } else if (getPlayer() != null) { // NPC?
          ExperienceHook hook = new ExperienceHook(getPlayer(), this.cp, cg);

          if (!hook.isCanceled()) {
            this.cp = this.cg;
            this.a.b(new Packet43Experience(this.ch, this.cg, this.cf));
          }
        }
        //
      }
    } catch (Throwable throwable) {
      CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
      CrashReportCategory crashreportcategory = crashreport.a("Player being ticked");

      this.a(crashreportcategory);
      throw new ReportedException(crashreport);
    }
  }
 public void reload() {
   this.e = Configuration.getNetConfig().getMaxPlayers();
 }
Esempio n. 12
0
  public void a(boolean var1) {
    super.F_();

    for (int var2 = 0; var2 < this.k.c(); ++var2) {
      OItemStack var3 = this.k.g_(var2);
      if (var3 != null && OItem.d[var3.c].t_() && this.a.b() <= 2) {
        OPacket var4 = ((OItemMapBase) OItem.d[var3.c]).c(var3, this.bi, this);
        if (var4 != null) {
          this.a.b(var4);
        }
      }
    }

    if (var1 && !this.f.isEmpty()) {
      OChunkCoordIntPair var14 = (OChunkCoordIntPair) this.f.get(0);
      double var5 = var14.a(this);

      for (int var7 = 0; var7 < this.f.size(); ++var7) {
        OChunkCoordIntPair var8 = (OChunkCoordIntPair) this.f.get(var7);
        double var9 = var8.a(this);
        if (var9 < var5) {
          var14 = var8;
          var5 = var9;
        }
      }

      if (var14 != null) {
        boolean var17 = false;
        if (this.a.b() < 4) {
          var17 = true;
        }

        if (var17) {
          OWorldServer var18 = (OWorldServer) getDimension().getHandle(); // this.b.a(this.w);
          if (var18.i(var14.a << 4, 0, var14.b << 4)) {
            OChunk var11 = var18.d(var14.a, var14.b);
            if (var11.k) {
              this.f.remove(var14);
              this.a.b((new OPacket51MapChunk(var18.d(var14.a, var14.b), true, 0)));
              List var12 =
                  var18.c(var14.a * 16, 0, var14.b * 16, var14.a * 16 + 16, 256, var14.b * 16 + 16);

              for (int var13 = 0; var13 < var12.size(); ++var13) {
                this.a((OTileEntity) var12.get(var13));
              }
            }
          }
        }
      }
    }

    if (this.J) {
      if (this.m != this.l) {
        this.F();
      }

      if (this.bh != null) {
        this.b(this.bh);
      } else {
        this.K += 0.0125F;
        if (this.K >= 1.0F) {
          this.K = 1.0F;
          this.I = 10;
          boolean var15 = false;
          byte var16;
          if (this.w == -1) {
            var16 = 0;
          } else {
            var16 = -1;
          }
          Location location = getPlayer().getLocation();
          int currDim = getPlayer().getDimension().getType().getId();
          location.setDimensionId(currDim == 0 ? -1 : 0);
          CancelableHook hook =
              (CancelableHook)
                  Canary.hooks().callCancelableHook(new TeleportHook(getPlayer(), location, true));
          if (!hook.isCanceled()) {
            this.b.h.switchDimension(this, var16, true);
            this.ci = -1;
            this.cf = -1;
            this.cg = -1;
            this.a(OAchievementList.x);
          }
        }
      }

      this.J = false;
    } else {
      if (this.K > 0.0F) {
        this.K -= 0.05F;
      }

      if (this.K < 0.0F) {
        this.K = 0.0F;
      }
    }

    if (this.I > 0) {
      --this.I;
    }

    if (this.ap != this.cf) {
      // Check if health is enabled
      if (!Configuration.getWorldConfig(bi.getCanaryDimension().getName()).isHealthEnabled()) {
        ap = 20;
        az = false;
      } else {
        // Call hook
        // CancelableHook hook = Canary.hooks().callCancelableHook(new HealthChangeHook());
        // if(hook.isCancelled){
        //  ap = cf;
        // }
      }
    }

    if (this.aD() != this.cf
        || this.cg != this.foodStats.getFoodLevel()
        || this.foodStats.getFoodSaturationLevel() == 0.0F != this.ch) {
      this.a.b(
          (new OPacket8UpdateHealth(
              this.aD(), this.foodStats.getFoodLevel(), this.foodStats.getFoodSaturationLevel())));
      this.cf = this.aD();
      this.cg = this.foodStats.getFoodLevel();
      this.ch = this.foodStats.getFoodSaturationLevel() == 0.0F;
    }

    // CanaryMod start - Experience Update
    if (this.N != this.ci) {
      if (!Configuration.getWorldConfig(bi.getCanaryDimension().getName())
          .isExperienceEnabled()) { // CanaryMod - check if Experience is enabled
        N = 0;
        M = 0;
      } else { // Call hook
        CancelableHook hook =
            (CancelableHook)
                Canary.hooks().callCancelableHook(new ExperienceHook(canaryPlayer, ci, N));
        if (hook.isCanceled()) {
          N = ci;
        }
      }
    }

    if (this.N != this.ci) {
      this.ci = this.N;
      this.a.b((new OPacket43Experience(this.O, this.N, this.M)));
    }
  }