private void createUIComponents() { SpinnerModel sm = new SpinnerNumberModel(1, 1, 5, 1); hasteSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) hasteSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); speedBoostSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) speedBoostSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); strengthSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) strengthSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); jumpBoostSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) jumpBoostSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); regenerationSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) regenerationSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); resistanceSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) resistanceSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); healthBoostSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) healthBoostSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 5, 1); absorptionSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) absorptionSpinner.getEditor()).getTextField().setEditable(false); sm = new SpinnerNumberModel(1, 1, 12, 1); selectionCountSpinner = new JSpinner(sm); ((JSpinner.DefaultEditor) selectionCountSpinner.getEditor()).getTextField().setEditable(false); }
@Override public void load(TagCompound tagCompound) { if (tagCompound.getCompoundData().containsKey("buff_speed_boost_enable")) { speedBoostChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_speed_boost_enable", TagByte.class).getBooleanData()) { speedBostEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_speed_boost_level")) { speedBoostSpinner.setValue( tagCompound.getAs("buff_speed_boost_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_haste_enable")) { hasteChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_haste_enable", TagByte.class).getBooleanData()) { hasteEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_haste_level")) { hasteSpinner.setValue(tagCompound.getAs("buff_haste_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_strength_enable")) { strengthChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_strength_enable", TagByte.class).getBooleanData()) { strengthEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_strength_level")) { strengthSpinner.setValue( tagCompound.getAs("buff_strength_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_jump_boost_enable")) { jumpBoostChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_jump_boost_enable", TagByte.class).getBooleanData()) { jumpBoostEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_jump_boost_level")) { jumpBoostSpinner.setValue( tagCompound.getAs("buff_jump_boost_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_regeneration_enable")) { regenerationChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_regeneration_enable", TagByte.class).getBooleanData()) { regenerationEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_regeneration_level")) { regenerationSpinner.setValue( tagCompound.getAs("buff_regeneration_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_resistance_enable")) { resistanceChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_resistance_enable", TagByte.class).getBooleanData()) { resistanceEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_resistance_level")) { resistanceSpinner.setValue( tagCompound.getAs("buff_resistance_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_fire_resistance_enable")) { fireResistanceChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_fire_resistance_enable", TagByte.class).getBooleanData()) { fireResistanceEnableCheckBox.setSelected(true); } } if (tagCompound.getCompoundData().containsKey("buff_water_breathing_enable")) { waterBreathingChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_water_breathing_enable", TagByte.class).getBooleanData()) { waterBreathingEnableCheckBox.setSelected(true); } } if (tagCompound.getCompoundData().containsKey("buff_invisibility_enable")) { invisibilityChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_invisibility_enable", TagByte.class).getBooleanData()) { invisibilityEnableCheckBox.setSelected(true); } } if (tagCompound.getCompoundData().containsKey("buff_night_vision_enable")) { nightVisionChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_night_vision_enable", TagByte.class).getBooleanData()) { nightVisionEnableCheckBox.setSelected(true); } } if (tagCompound.getCompoundData().containsKey("buff_health_boost_enable")) { healthBoostChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_health_boost_enable", TagByte.class).getBooleanData()) { healthBoostEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_health_boost_level")) { healthBoostSpinner.setValue( tagCompound.getAs("buff_health_boost_level", TagInt.class).getIntData()); } } } if (tagCompound.getCompoundData().containsKey("buff_absorption_enable")) { absorptionChangeCheckBox.setSelected(true); if (tagCompound.getAs("buff_absorption_enable", TagByte.class).getBooleanData()) { absorptionEnableCheckBox.setSelected(true); if (tagCompound.getCompoundData().containsKey("buff_absorption_level")) { absorptionSpinner.setValue( tagCompound.getAs("buff_absorption_level", TagInt.class).getIntData()); } } } if (!tagCompound.getCompoundData().containsKey("addset_duration") || tagCompound.getAs("addset_duration", TagString.class).getStringData().equals("add")) { addDurationRadioButton.setSelected(true); } else { setDurationRadioButton.setSelected(true); } if (tagCompound.getCompoundData().containsKey("duration")) { durationInput.setText("" + tagCompound.getAs("duration", TagInt.class).getIntData()); } if (!tagCompound.getCompoundData().containsKey("addset_range") || tagCompound.getAs("addset_range", TagString.class).getStringData().equals("add")) { addRangeRadioButton.setSelected(true); } else { setRangeRadioButton.setSelected(true); } if (tagCompound.getCompoundData().containsKey("range")) { rangeInput.setText("" + tagCompound.getAs("range", TagDouble.class).getDoubleData()); } if (tagCompound.getCompoundData().containsKey("addset_selection_count") && tagCompound .getAs("addset_selection_count", TagString.class) .getStringData() .equals("add")) { addSelectionCount.setSelected(false); } else { setSelectionCount.setSelected(true); } if (tagCompound.getCompoundData().containsKey("selection_count")) { selectionCountSpinner.setValue( tagCompound.getAs("selection_count", TagInt.class).getIntData()); } }
@Override public TagCompound save() { if (speedBoostChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_speed_boost_enable", new TagByte(speedBostEnableCheckBox.isSelected())); if (speedBostEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_speed_boost_level", new TagInt(((Number) jumpBoostSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_speed_boost_enable"); tagCompound.getCompoundData().remove("buff_speed_boost_level"); } if (hasteChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_haste_enable", new TagByte(hasteEnableCheckBox.isSelected())); if (hasteEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_haste_level", new TagInt(((Number) hasteSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_haste_enable"); tagCompound.getCompoundData().remove("buff_haste_level"); } if (strengthChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_strength_enable", new TagByte(strengthEnableCheckBox.isSelected())); if (strengthEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_strength_level", new TagInt(((Number) strengthSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_strength_enable"); tagCompound.getCompoundData().remove("buff_strength_level"); } if (jumpBoostChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_jump_boost_enable", new TagByte(jumpBoostEnableCheckBox.isSelected())); if (jumpBoostEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_jump_boost_level", new TagInt(((Number) jumpBoostSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_jump_boost_enable"); tagCompound.getCompoundData().remove("buff_jump_boost_level"); } if (regenerationChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_regeneration_enable", new TagByte(regenerationEnableCheckBox.isSelected())); if (regenerationEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_regeneration_level", new TagInt(((Number) regenerationSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_regeneration_enable"); tagCompound.getCompoundData().remove("buff_regeneration_level"); } if (resistanceChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_resistance_enable", new TagByte(resistanceEnableCheckBox.isSelected())); if (resistanceEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_resistance_level", new TagInt(((Number) resistanceSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_resistance_enable"); tagCompound.getCompoundData().remove("buff_resistance_level"); } if (fireResistanceChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_fire_resistance_enable", new TagByte(fireResistanceEnableCheckBox.isSelected())); } else { tagCompound.getCompoundData().remove("buff_fire_resistance_enable"); } if (waterBreathingChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_water_breathing_enable", new TagByte(waterBreathingEnableCheckBox.isSelected())); } else { tagCompound.getCompoundData().remove("buff_water_breathing_enable"); } if (invisibilityChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_invisibility_enable", new TagByte(invisibilityEnableCheckBox.isSelected())); } else { tagCompound.getCompoundData().remove("buff_invisibility_enable"); } if (nightVisionChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_night_vision_enable", new TagByte(nightVisionEnableCheckBox.isSelected())); } else { tagCompound.getCompoundData().remove("buff_night_vision_enable"); } if (healthBoostChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_health_boost_enable", new TagByte(healthBoostEnableCheckBox.isSelected())); if (healthBoostEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_health_boost_level", new TagInt(((Number) healthBoostSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_health_boost_enable"); tagCompound.getCompoundData().remove("buff_health_boost_level"); } if (absorptionChangeCheckBox.isSelected()) { tagCompound .getCompoundData() .put("buff_absorption_enable", new TagByte(absorptionEnableCheckBox.isSelected())); if (absorptionEnableCheckBox.isSelected()) { tagCompound .getCompoundData() .put( "buff_absorption_level", new TagInt(((Number) absorptionSpinner.getValue()).intValue())); } } else { tagCompound.getCompoundData().remove("buff_absorption_enable"); tagCompound.getCompoundData().remove("buff_absorption_level"); } tagCompound .getCompoundData() .put("addset_duration", new TagString(addDurationRadioButton.isSelected() ? "add" : "set")); tagCompound .getCompoundData() .put("duration", new TagInt(Integer.parseInt(durationInput.getText()))); tagCompound .getCompoundData() .put("addset_range", new TagString(addRangeRadioButton.isSelected() ? "add" : "set")); tagCompound .getCompoundData() .put("range", new TagDouble(Double.parseDouble(rangeInput.getText()))); tagCompound .getCompoundData() .put( "addset_selection_count", new TagString(addSelectionCount.isSelected() ? "add" : "set")); tagCompound .getCompoundData() .put("selection_count", new TagInt(((Number) selectionCountSpinner.getValue()).intValue())); return tagCompound; }