Skip to content

Commit 91626a3

Browse files
Merge pull request #344 from VolmitSoftware/Development
Development
2 parents fc7b323 + dfe28e3 commit 91626a3

File tree

14 files changed

+109
-72
lines changed

14 files changed

+109
-72
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plugins {
2323
id "de.undercouch.download" version "5.0.1"
2424
}
2525

26-
version '1.4.19-1.19.2'
26+
version '1.4.20-1.19.2'
2727
def nmsVersion = "1.19.2" //[NMS]
2828
def apiVersion = '1.19'
2929
def specialSourceVersion = '1.11.0' //[NMS]

src/main/java/com/volmit/adapt/Adapt.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ public static void autoUpdateCheck() {
9696
while ((inputLine = in.readLine()) != null) {
9797
if (inputLine.contains("version '")) {
9898
String version = inputLine.remove("version '").remove("'").remove("// Needs to be version specific").remove(" ");
99-
if (!version.equals(instance.getDescription().getVersion())) {
99+
if (instance.getDescription().getVersion().contains("development")) {
100+
info("Development build detected. Skipping update check.");
101+
return;
102+
}
103+
else if (!version.equals(instance.getDescription().getVersion())) {
100104
info("Please update your Adapt plugin to the latest version! (Current: " + instance.getDescription().getVersion() + " Latest: " + version + ")");
101105
} else {
102106
info("You are running the latest version of Adapt!");

src/main/java/com/volmit/adapt/AdaptConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class AdaptConfig {
3838
private static AdaptConfig config = null;
3939
public boolean debug = false;
4040
public boolean autoUpdateCheck = true;
41+
public boolean autoUpdateLanguage = true;
4142
public boolean splashScreen = true;
4243
public boolean xpInCreative = false;
4344
public boolean allowAdaptationsInCreative = false;
@@ -65,6 +66,7 @@ public class AdaptConfig {
6566
private boolean actionbarNotifyXp = true;
6667
private boolean actionbarNotifyLevel = true;
6768
private boolean unlearnAllButton = false;
69+
private boolean potionStackingPreventionInAllSKills = false;
6870
private SqlSettings sql = new SqlSettings();
6971

7072
@Setter

src/main/java/com/volmit/adapt/api/Component.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,19 @@ default void addPotionStacks(Player p, PotionEffectType potionEffect, int amplif
185185
if (activeList.size() > 0) {
186186
for (PotionEffectType type : activeList) {
187187
if (type.equals(potionEffect)) {
188-
if (overlap) {
189-
p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f);
188+
if (!AdaptConfig.get().isPotionStackingPreventionInAllSKills()) {
189+
if (overlap) {
190+
p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f);
191+
int newAmplifier = Objects.requireNonNull(p.getPotionEffect(type)).getAmplifier();
192+
int newDuration = Objects.requireNonNull(p.getPotionEffect(type)).getDuration();
193+
p.removePotionEffect(type);
194+
p.addPotionEffect(new PotionEffect(potionEffect, newDuration + duration, newAmplifier + amplifier, false, false));
195+
}
190196
int newAmplifier = Objects.requireNonNull(p.getPotionEffect(type)).getAmplifier();
191197
int newDuration = Objects.requireNonNull(p.getPotionEffect(type)).getDuration();
192198
p.removePotionEffect(type);
193-
p.addPotionEffect(new PotionEffect(potionEffect, newDuration + duration, newAmplifier + amplifier, false, false));
199+
p.addPotionEffect(new PotionEffect(potionEffect, newDuration, newAmplifier + 1, false, false));
194200
}
195-
int newAmplifier = Objects.requireNonNull(p.getPotionEffect(type)).getAmplifier();
196-
int newDuration = Objects.requireNonNull(p.getPotionEffect(type)).getDuration();
197-
p.removePotionEffect(type);
198-
p.addPotionEffect(new PotionEffect(potionEffect, newDuration, newAmplifier + 1, false, false));
199201
}
200202
}
201203

src/main/java/com/volmit/adapt/api/notification/Notifier.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import com.volmit.adapt.util.Form;
2727
import com.volmit.adapt.util.M;
2828
import lombok.Data;
29+
import lombok.EqualsAndHashCode;
2930

3031
import java.util.ArrayList;
3132
import java.util.HashMap;
3233
import java.util.List;
3334
import java.util.Map;
3435

36+
@EqualsAndHashCode(callSuper = true)
3537
@Data
3638
public class Notifier extends TickedObject {
3739
private final List<Notification> queue;

src/main/java/com/volmit/adapt/api/recipe/AdaptRecipe.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class Smoker implements AdaptRecipe {
8282
private String key;
8383
private ItemStack result;
8484
private Material ingredient;
85-
private float experience = 1;
86-
private int cookTime = 20;
85+
private float experience;
86+
private int cookTime;
8787

8888
@Override
8989
public ItemStack getResult() {
@@ -115,8 +115,10 @@ class Furnace implements AdaptRecipe {
115115
private String key;
116116
private ItemStack result;
117117
private Material ingredient;
118-
private float experience = 1;
119-
private int cookTime = 20;
118+
// private float experience = 1;
119+
// private int cookTime = 20;
120+
private float experience;
121+
private int cookTime;
120122

121123
@Override
122124
public ItemStack getResult() {
@@ -148,8 +150,8 @@ class Campfire implements AdaptRecipe {
148150
private String key;
149151
private ItemStack result;
150152
private Material ingredient;
151-
private float experience = 1;
152-
private int cookTime = 20;
153+
private float experience;
154+
private int cookTime;
153155

154156
@Override
155157
public ItemStack getResult() {
@@ -180,8 +182,8 @@ class Blast implements AdaptRecipe {
180182
private String key;
181183
private ItemStack result;
182184
private Material ingredient;
183-
private float experience = 1;
184-
private int cookTime = 20;
185+
private float experience;
186+
private int cookTime;
185187

186188
@Override
187189
public ItemStack getResult() {

src/main/java/com/volmit/adapt/content/adaptation/brewing/BrewingDecay.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ public BrewingDecay() {
4747
.id("brewing-decay-1")
4848
.brewingTime(320)
4949
.fuelCost(16)
50-
.ingredient(Material.AMETHYST_SHARD)
50+
.ingredient(Material.POISONOUS_POTATO)
5151
.basePotion(PotionBuilder.vanilla(PotionBuilder.Type.REGULAR, PotionType.WEAKNESS, false, false))
5252
.result(PotionBuilder.of(PotionBuilder.Type.REGULAR)
5353
.setName("Bottled Decay")
5454
.setColor(Color.MAROON)
55-
.addEffect(PotionEffectType.FAST_DIGGING, 600, 1, true, true, true)
55+
.addEffect(PotionEffectType.WITHER, 300, 1, true, true, true)
5656
.build())
5757
.build());
5858
registerBrewingRecipe(BrewingRecipe.builder()
5959
.id("brewing-decay-2")
6060
.brewingTime(320)
6161
.fuelCost(32)
62-
.ingredient(Material.AMETHYST_BLOCK)
62+
.ingredient(Material.CRIMSON_ROOTS)
6363
.basePotion(PotionBuilder.vanilla(PotionBuilder.Type.REGULAR, PotionType.WEAKNESS, false, false))
6464
.result(PotionBuilder.of(PotionBuilder.Type.REGULAR)
6565
.setName("Bottled Decay 2")
6666
.setColor(Color.MAROON)
67-
.addEffect(PotionEffectType.WITHER, 300, 2, true, true, true)
67+
.addEffect(PotionEffectType.WITHER, 150, 2, true, true, true)
6868
.build())
6969
.build());
7070
}

src/main/java/com/volmit/adapt/content/adaptation/brewing/BrewingSuperHeated.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@
3434
import org.bukkit.event.EventPriority;
3535
import org.bukkit.event.inventory.BrewEvent;
3636
import org.bukkit.event.inventory.InventoryClickEvent;
37+
import org.bukkit.event.inventory.InventoryMoveItemEvent;
3738
import org.bukkit.event.inventory.InventoryType;
3839

39-
import java.util.HashSet;
40+
import java.util.HashMap;
4041
import java.util.Iterator;
41-
import java.util.Set;
42+
import java.util.Map;
4243

4344

4445
public class BrewingSuperHeated extends SimpleAdaptation<BrewingSuperHeated.Config> {
45-
private final Set<Block> activeStands = new HashSet<>();
46+
47+
private static final int MAX_CHECKS_BEFORE_REMOVE = 20;
48+
private final Map<Block, Integer> activeStands = new HashMap<>();
4649

4750
public BrewingSuperHeated() {
4851
super("brewing-super-heated");
@@ -71,14 +74,26 @@ public double getFireBoost(double factor) {
7174
return (getConfig().fireMultiplier) * (getConfig().multiplierFactor * factor);
7275
}
7376

77+
@EventHandler(priority = EventPriority.HIGHEST)
78+
public void on(InventoryMoveItemEvent e) {
79+
if (e.isCancelled()) {
80+
return;
81+
}
82+
J.s(() -> {
83+
if (e.getDestination().getType().equals(InventoryType.BREWING)) {
84+
activeStands.put(e.getDestination().getLocation().getBlock(), MAX_CHECKS_BEFORE_REMOVE);
85+
}
86+
});
87+
}
88+
7489
@EventHandler(priority = EventPriority.HIGHEST)
7590
public void on(BrewEvent e) {
7691
if (e.isCancelled()) {
7792
return;
7893
}
7994
J.s(() -> {
8095
if (((BrewingStand) e.getBlock().getState()).getBrewingTime() > 0) {
81-
activeStands.add(e.getBlock());
96+
activeStands.put(e.getBlock(), MAX_CHECKS_BEFORE_REMOVE);
8297
}
8398
});
8499
}
@@ -89,7 +104,7 @@ public void on(InventoryClickEvent e) {
89104
return;
90105
}
91106
if (e.getView().getTopInventory().getType().equals(InventoryType.BREWING)) {
92-
activeStands.add(e.getView().getTopInventory().getLocation().getBlock());
107+
activeStands.put(e.getView().getTopInventory().getLocation().getBlock(), MAX_CHECKS_BEFORE_REMOVE);
93108
}
94109
}
95110

@@ -100,7 +115,7 @@ public void onTick() {
100115
return;
101116
}
102117

103-
Iterator<Block> it = activeStands.iterator();
118+
Iterator<Block> it = activeStands.keySet().iterator();
104119

105120
J.s(() -> {
106121
while (it.hasNext()) {
@@ -110,9 +125,13 @@ public void onTick() {
110125
if (b.getBrewingTime() <= 0) {
111126
J.s(() -> {
112127
BrewingStand bb = (BrewingStand) s.getBlock().getState();
113-
114128
if (bb.getBrewingTime() <= 0) {
115-
activeStands.remove(b.getBlock());
129+
if (activeStands.get(b.getBlock()) == 0) {
130+
activeStands.remove(b.getBlock());
131+
}
132+
if(activeStands.containsKey(b.getBlock())) {
133+
activeStands.put(b.getBlock(), activeStands.get(b.getBlock()) - 1);
134+
}
116135
}
117136
});
118137
continue;

src/main/java/com/volmit/adapt/util/JSONArray.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ public JSONArray put(Collection<Object> value) {
681681
* @throws JSONException if the value is not finite.
682682
*/
683683
public JSONArray put(double value) throws JSONException {
684-
Double d = new Double(value);
684+
Double d = value;
685685
JSONObject.testValidity(d);
686686
this.put(d);
687687
return this;
@@ -694,7 +694,7 @@ public JSONArray put(double value) throws JSONException {
694694
* @return this.
695695
*/
696696
public JSONArray put(int value) {
697-
this.put(new Integer(value));
697+
this.put( Integer.valueOf(value));
698698
return this;
699699
}
700700

@@ -705,7 +705,7 @@ public JSONArray put(int value) {
705705
* @return this.
706706
*/
707707
public JSONArray put(long value) {
708-
this.put(new Long(value));
708+
this.put( Long.valueOf(value));
709709
return this;
710710
}
711711

@@ -774,7 +774,7 @@ public JSONArray put(int index, Collection<Object> value) throws JSONException {
774774
* @throws JSONException If the index is negative or if the value is not finite.
775775
*/
776776
public JSONArray put(int index, double value) throws JSONException {
777-
this.put(index, new Double(value));
777+
this.put(index, Double.valueOf(value));
778778
return this;
779779
}
780780

@@ -789,7 +789,7 @@ public JSONArray put(int index, double value) throws JSONException {
789789
* @throws JSONException If the index is negative.
790790
*/
791791
public JSONArray put(int index, int value) throws JSONException {
792-
this.put(index, new Integer(value));
792+
this.put(index, Integer.valueOf(value));
793793
return this;
794794
}
795795

@@ -804,7 +804,7 @@ public JSONArray put(int index, int value) throws JSONException {
804804
* @throws JSONException If the index is negative.
805805
*/
806806
public JSONArray put(int index, long value) throws JSONException {
807-
this.put(index, new Long(value));
807+
this.put(index, Long.valueOf(value));
808808
return this;
809809
}
810810

src/main/java/com/volmit/adapt/util/JSONObject.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ public static Object stringToValue(String string) {
507507
return d;
508508
}
509509
} else {
510-
Long myLong = new Long(string);
511-
if (string.equals(myLong.toString())) {
512-
if (myLong == myLong.intValue()) {
513-
return myLong.intValue();
510+
long myLong = Long.parseLong(string);
511+
if (string.equals(Long.toString(myLong))) {
512+
if (myLong == (int) myLong) {
513+
return (int) myLong;
514514
} else {
515515
return myLong;
516516
}
@@ -1348,7 +1348,7 @@ public JSONObject put(String key, Collection<Object> value) throws JSONException
13481348
* @throws JSONException If the key is null or if the number is invalid.
13491349
*/
13501350
public JSONObject put(String key, double value) throws JSONException {
1351-
this.put(key, new Double(value));
1351+
this.put(key, Double.valueOf(value));
13521352
return this;
13531353
}
13541354

@@ -1361,7 +1361,7 @@ public JSONObject put(String key, double value) throws JSONException {
13611361
* @throws JSONException If the key is null.
13621362
*/
13631363
public JSONObject put(String key, int value) throws JSONException {
1364-
this.put(key, new Integer(value));
1364+
this.put(key, Integer.valueOf(value));
13651365
return this;
13661366
}
13671367

@@ -1374,7 +1374,7 @@ public JSONObject put(String key, int value) throws JSONException {
13741374
* @throws JSONException If the key is null.
13751375
*/
13761376
public JSONObject put(String key, long value) throws JSONException {
1377-
this.put(key, new Long(value));
1377+
this.put(key, Long.valueOf(value));
13781378
return this;
13791379
}
13801380

0 commit comments

Comments
 (0)