@Override public void change(Event e, Object[] delta, Changer.ChangeMode mode){ if (mode == ChangeMode.SET) { String w = (String)delta[0]; WeatherType t = null; try { t = WeatherType.valueOf(w.replace("\"", "").trim().replace(" ", "_").toUpperCase()); } catch (IllegalArgumentException error) { Bukkit.getConsoleSender().sendMessage(Skellett.cc(Skellett.prefix + "&cUnknown weather type " + w)); return; } if (t != null) { player.getSingle(e).setPlayerWeather(t); } } else if (mode == ChangeMode.RESET) { player.getSingle(e).setPlayerWeather(WeatherType.CLEAR); } }
public void setPlayerWeather(WeatherType type, boolean plugin) { if (!plugin && this.weather != null) { return; } if (plugin) { this.weather = type; } if (type == WeatherType.DOWNFALL) { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F))); // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F))); } else { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); } }
@Override public void setWeather(PlotWeather weather) { switch (weather) { case CLEAR: this.player.setPlayerWeather(WeatherType.CLEAR); break; case RAIN: this.player.setPlayerWeather(WeatherType.DOWNFALL); break; case RESET: this.player.resetPlayerWeather(); break; default: this.player.resetPlayerWeather(); break; } }
public void setPlayerWeather(WeatherType type, boolean plugin) { if (!plugin && this.weather != null) { return; } if (plugin) { this.weather = type; } if (type == WeatherType.DOWNFALL) { this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(2, 0)); // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F))); // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F))); } else { this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0)); } }
public void updateWeather(float oldRain, float newRain, float oldThunder, float newThunder) { if (this.weather == null) { // Vanilla if (oldRain != newRain) { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, newRain)); } } else { // Plugin if (pluginRainPositionPrevious != pluginRainPosition) { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, pluginRainPosition)); } } if (oldThunder != newThunder) { if (weather == WeatherType.DOWNFALL || weather == null) { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, newThunder)); } else { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, 0)); } } }
@Override public boolean handlePlayer(TregminePlayer player, String[] args) { if (!player.getRank().canSetWeather()) { return true; } if (args.length != 1) { player.sendMessage("/weather <downfall or clear>"); player.resetPlayerWeather(); return true; } try { WeatherType type = WeatherType.valueOf(args[0].toUpperCase()); player.setPlayerWeather(type); player.sendMessage(YELLOW + "Weather set to " + type); } catch (IllegalArgumentException e) { return false; } return true; }
@Override public void setPlayerWeather(WeatherType type) { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
@Test public void testValueFromEnum() throws InputException { Class[] inputTypes = { WeatherType.class, EquipmentSlot.class, MainHand.class, PermissionDefault.class }; String[] input = { "downfall", "HeAd", "lEfT", "NOT_OP" }; Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null); // First let's make sure we didn't lose anything, or get anything assertEquals(inputTypes.length, output.length); // Next let's make sure everything is the right type assertTrue(output[0] instanceof WeatherType); assertTrue(output[1] instanceof EquipmentSlot); assertTrue(output[2] instanceof MainHand); assertTrue(output[3] instanceof PermissionDefault); // Finally, let's make sure the values are correct assertSame(output[0], WeatherType.DOWNFALL); assertSame(output[1], EquipmentSlot.HEAD); assertSame(output[2], MainHand.LEFT); assertSame(output[3], PermissionDefault.NOT_OP); }
@Override protected void onCommand(CommandSender sender, String[] args) { if (args[0].equalsIgnoreCase("reset")) { ((Player) sender).resetPlayerWeather(); sender.sendMessage(ChatColor.GOLD + "Weather returned to normal."); return; } ((Player) sender).setPlayerWeather(WeatherType.valueOf(args[0].toUpperCase())); sender.sendMessage(ChatColor.GOLD + "Weather set to " + ChatColor.RED + args[0]); }
@Override @Nullable protected WeatherType[] get(Event e) { if (player != null && player.getSingle(e).getPlayerWeather() != null) { return new WeatherType[]{player.getSingle(e).getPlayerWeather()}; } return null; }
protected void o() { boolean flag = this.Q(); super.o(); /* CraftBukkit start if (this.m != this.n) { this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.n), this.worldProvider.dimension); } if (this.o != this.p) { this.server.getPlayerList().a(new PacketPlayOutGameStateChange(8, this.p), this.worldProvider.dimension); } if (flag != this.Q()) { if (flag) { this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(2, 0.0F)); } else { this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(1, 0.0F)); } this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.n)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.p)); } // */ if (flag != this.Q()) { // Only send weather packets to those affected for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); } } // CraftBukkit end } }
private void setWeather(Player player, String str) { switch (str.toLowerCase()) { case "clear": { player.setPlayerWeather(WeatherType.CLEAR); return; } case "rain": { player.setPlayerWeather(WeatherType.DOWNFALL); return; } } }
protected void o() { boolean flag = this.Q(); super.o(); if (flag != this.Q()) { // CraftBukkit start - Only send weather packets to those affected for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); } } // CraftBukkit end } }
public void setPlayerWeather(WeatherType type, boolean plugin) { if (!plugin && this.weather != null) { return; } if (plugin) { this.weather = type; } this.playerConnection.sendPacket(new Packet70Bed(type == WeatherType.DOWNFALL ? 1 : 2, 0)); }
protected void t() { boolean flag = this.W(); super.t(); /* CraftBukkit start if (this.n != this.o) { this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID()); } if (this.p != this.q) { this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(8, this.q)), this.worldProvider.getDimensionManager().getDimensionID()); } if (flag != this.W()) { if (flag) { this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(2, 0.0F)); } else { this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(1, 0.0F)); } this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q)); } // */ if (flag != this.W()) { // Only send weather packets to those affected for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); } } } for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { ((EntityPlayer) this.players.get(i)).updateWeather(this.n, this.o, this.p, this.q); } } // CraftBukkit end }
public void setPlayerWeather(WeatherType type, boolean plugin) { if (!plugin && this.weather != null) { return; } if (plugin) { this.weather = type; } if (type == WeatherType.DOWNFALL) { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); } else { this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); } }
public void tickWeather() { if (this.weather == null) return; pluginRainPositionPrevious = pluginRainPosition; if (weather == WeatherType.DOWNFALL) { pluginRainPosition += 0.01; } else { pluginRainPosition -= 0.01; } pluginRainPosition = MathHelper.a(pluginRainPosition, 0.0F, 1.0F); }
public static void setWeather(final Player player, long ticks) { // Set the weather player.setPlayerWeather(WeatherType.DOWNFALL); // Create the runnable to switch back Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(DemigodsPlugin.getInst(), new BukkitRunnable() { @Override public void run() { player.resetPlayerWeather(); } }, ticks); }
protected void n() { boolean flag = this.O(); super.n(); if (flag != this.O()) { // CraftBukkit start - Only send weather packets to those affected for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); } } // CraftBukkit end } }
@Override public WeatherType getPlayerWeather() { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
@Override public WeatherType getPlayerWeather() { return null; }
@Override public WeatherType getPlayerWeather() { throw Pokkit.unsupported(); }
@Override public void setPlayerWeather(WeatherType arg0) { throw Pokkit.unsupported(); }
@Override public Class<? extends WeatherType> getReturnType() { return WeatherType.class; }
public WeatherType getPlayerWeather() { throw new NotImplementedException("getPlayerWeather()"); }
public void setPlayerWeather(WeatherType type) { throw new NotImplementedException("setPlayerWeather(WeatherType)"); }
public WeatherType getPlayerWeather() { return this.weather; }
public void resetPlayerWeather() { this.weather = null; this.setPlayerWeather(this.world.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); }
@Override public WeatherType getPlayerWeather() { throw new UnsupportedOperationException(); }
@Override public void setPlayerWeather(WeatherType type) { throw new UnsupportedOperationException(); }
protected void updateWeather() { boolean flag = this.isRaining(); super.updateWeather(); /* CraftBukkit start if (this.prevRainingStrength != this.rainingStrength) { this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); } if (this.prevThunderingStrength != this.thunderingStrength) { this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); } if (flag != this.isRaining()) { if (flag) { this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(2, 0.0F)); } else { this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(1, 0.0F)); } this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(7, this.rainingStrength)); this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(8, this.thunderingStrength)); } // */ if (flag != this.isRaining()) { // Only send weather packets to those affected for (int i = 0; i < this.playerEntities.size(); ++i) { if (((EntityPlayerMP) this.playerEntities.get(i)).worldObj == this) { ((EntityPlayerMP) this.playerEntities.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); } } // CraftBukkit end } }
public void resetPlayerWeather() { this.weather = null; this.setPlayerWeather(this.worldObj.getWorldInfo().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); }