Skip to content

Commit 848c702

Browse files
committed
Merge branch 'api-8' into api-9
2 parents 33dd3d1 + 6bf979b commit 848c702

File tree

14 files changed

+52
-75
lines changed

14 files changed

+52
-75
lines changed

src/main/java/org/spongepowered/api/Server.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.spongepowered.api.scoreboard.Scoreboard;
4343
import org.spongepowered.api.service.ServiceProvider;
4444
import org.spongepowered.api.user.UserManager;
45+
import org.spongepowered.api.util.Ticks;
4546
import org.spongepowered.api.util.locale.LocaleSource;
4647
import org.spongepowered.api.world.difficulty.Difficulty;
4748
import org.spongepowered.api.world.generation.config.WorldGenerationConfig;
@@ -278,7 +279,7 @@ public interface Server extends ForwardingAudience, Engine, LocaleSource {
278279
*
279280
* @return The number of ticks since this server started running
280281
*/
281-
int runningTimeTicks();
282+
Ticks runningTimeTicks();
282283

283284
/**
284285
* Gets the message channel that server-wide messages are sent through.

src/main/java/org/spongepowered/api/config/DefaultConfig.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,23 @@
2727
import com.google.inject.BindingAnnotation;
2828
import com.google.inject.Inject;
2929
import org.spongepowered.configurate.loader.ConfigurationLoader;
30+
import org.spongepowered.configurate.reference.ConfigurationReference;
3031

31-
import java.io.File;
3232
import java.lang.annotation.ElementType;
3333
import java.lang.annotation.Retention;
3434
import java.lang.annotation.RetentionPolicy;
3535
import java.lang.annotation.Target;
3636
import java.nio.file.Path;
3737

3838
/**
39-
* Provides an convenient injection for {@link ConfigRoot#config()} or
39+
* Provides a convenient injection for {@link ConfigRoot#config()} or
4040
* {@link ConfigRoot#configPath()}.
4141
*
42-
* <p>Use this annotation on a {@link File} or {@link Path} if you want the
42+
* <p>Use this annotation on a {@link Path} if you want the
4343
* pathname to the default configuration. Or instead, use this annotation on a
44-
* {@link ConfigurationLoader} to get an instance of that. Remember that
44+
* {@link ConfigurationLoader ConfigurationLoader&lt;CommentedConigurationNode&gt;}
45+
* or {@link ConfigurationReference ConfigurationReference&lt;CommentedConigurationNode&gt;}
46+
* to get a loader/reference for a HOCON based configuration file. Remember that
4547
* {@link Inject} is also necessary.</p>
4648
*
4749
* @see ConfigManager For getting configuration without injection

src/main/java/org/spongepowered/api/data/Key.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ public interface Key<V extends Value<?>> extends ResourceKeyed {
8181
* Sponge. If custom keys for {@link DataHolder}s is desired to be
8282
* persisted, a {@link DataRegistration} is required.
8383
*
84-
* <p>Registration of a custom created {@link Key} is required through
85-
* {@link RegisterRegistryValueEvent}. The
86-
* registration of a {@link DataRegistration} is done separately.
87-
* </p>
88-
*
8984
* @see DataRegistration
9085
* @return The key builder
9186
*/

src/main/java/org/spongepowered/api/entity/ai/goal/builtin/creature/RangedAttackAgainstAgentGoal.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.spongepowered.api.entity.ai.goal.Goal;
3030
import org.spongepowered.api.entity.ai.goal.GoalBuilder;
3131
import org.spongepowered.api.entity.living.Ranger;
32+
import org.spongepowered.api.util.Ticks;
3233

3334
/**
3435
* An {@link Goal} which uses the ranging aspect of the Ranger to attack
@@ -68,7 +69,7 @@ static Builder builder() {
6869
*
6970
* @return The delay in ticks between attempts to attack
7071
*/
71-
int delayBetweenAttacks();
72+
Ticks delayBetweenAttacks();
7273

7374
/**
7475
* The time, in ticks, this {@link Ranger} will wait before attacking
@@ -77,7 +78,7 @@ static Builder builder() {
7778
* @param delay The delay, in ticks
7879
* @return This goal, for chaining
7980
*/
80-
RangedAttackAgainstAgentGoal setDelayBetweenAttacks(int delay);
81+
RangedAttackAgainstAgentGoal setDelayBetweenAttacks(Ticks delay);
8182

8283
/**
8384
* Gets the radius of which the owning {@link Ranger} will attempt to
@@ -101,7 +102,7 @@ interface Builder extends GoalBuilder<Ranger, RangedAttackAgainstAgentGoal, Buil
101102

102103
Builder moveSpeed(double speed);
103104

104-
Builder delayBetweenAttacks(int delay);
105+
Builder delayBetweenAttacks(Ticks delay);
105106

106107
Builder attackRadius(float radius);
107108
}

src/main/java/org/spongepowered/api/entity/living/player/CooldownTracker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
package org.spongepowered.api.entity.living.player;
2626

2727
import org.spongepowered.api.item.ItemType;
28+
import org.spongepowered.api.util.Ticks;
2829

30+
import java.util.Optional;
2931
import java.util.OptionalDouble;
30-
import java.util.OptionalInt;
3132

3233
/**
3334
* Provides access to the item cooldowns of a {@link Player}.
@@ -51,7 +52,7 @@ public interface CooldownTracker {
5152
* @return The cooldown remaining for this item type in ticks, if not
5253
* on cooldown
5354
*/
54-
OptionalInt cooldown(ItemType type);
55+
Optional<Ticks> cooldown(ItemType type);
5556

5657
/**
5758
* Sets the cooldown for the specified {@link ItemType} for the
@@ -62,7 +63,7 @@ public interface CooldownTracker {
6263
* @return False if setting the cooldown failed, possibly due to the event
6364
* being cancelled
6465
*/
65-
boolean setCooldown(ItemType type, int ticks);
66+
boolean setCooldown(ItemType type, Ticks ticks);
6667

6768
/**
6869
* Resets the cooldown of the specified {@link ItemType} for the

src/main/java/org/spongepowered/api/event/entity/IgniteEntityEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.entity.Entity;
2828
import org.spongepowered.api.event.Cancellable;
2929
import org.spongepowered.api.event.Event;
30+
import org.spongepowered.api.util.Ticks;
3031

3132
/**
3233
* An event that occurs when an entity becomes ignited.
@@ -44,20 +45,20 @@ public interface IgniteEntityEvent extends Event, Cancellable {
4445
* Gets the original amount of fire ticks the entity will remain on fire.
4546
* @return The original fire ticks
4647
*/
47-
int originalFireTicks();
48+
Ticks originalFireTicks();
4849

4950
/**
5051
* Gets the amount of ticks the entity will remain on fire.
5152
*
5253
* @return The amount of ticks the entity will remain on fire
5354
*/
54-
int fireTicks();
55+
Ticks fireTicks();
5556

5657
/**
5758
* Sets the amount of ticks the entity will remain on fire.
5859
*
5960
* @param fireTicks The amount of ticks the entity will remain on fire
6061
*/
61-
void setFireTicks(int fireTicks);
62+
void setFireTicks(Ticks fireTicks);
6263

6364
}

src/main/java/org/spongepowered/api/event/entity/SpawnEntityEvent.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
*
3939
* <p>Note: To determine the {@link Cause}, refer to package
4040
* org.spongepowered.api.event.cause.entity.spawn.</p>
41-
*
42-
* <p>For players, this event is fired before they have fully
43-
* joined the world. {@link ServerSideConnectionEvent} is the
44-
* recommended event to interact with connecting players.</p>
4541
*/
4642
@GenerateFactoryMethod
4743
@ImplementedBy(value = AbstractSpawnEntityEvent.class, priority = 2)

src/main/java/org/spongepowered/api/event/entity/living/player/CooldownEvent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import org.spongepowered.api.event.Cancellable;
3030
import org.spongepowered.api.event.Event;
3131
import org.spongepowered.api.item.ItemType;
32+
import org.spongepowered.api.util.Ticks;
3233

34+
import java.util.Optional;
3335
import java.util.OptionalInt;
3436

3537
/**
@@ -64,28 +66,28 @@ interface Set extends CooldownEvent, Cancellable {
6466
*
6567
* @return The cooldown of the item type beforehand
6668
*/
67-
OptionalInt startingCooldown();
69+
Optional<Ticks> startingCooldown();
6870

6971
/**
7072
* Gets the original new set cooldown at the beginning of the event.
7173
*
7274
* @return The originally set cooldown
7375
*/
74-
int originalNewCooldown();
76+
Ticks originalNewCooldown();
7577

7678
/**
7779
* Gets the new cooldown the item type has for the player.
7880
*
7981
* @return The new cooldown of the item type
8082
*/
81-
int newCooldown();
83+
Ticks newCooldown();
8284

8385
/**
8486
* Sets the new cooldown for the item type for the player.
8587
*
8688
* @param ticks The amount of ticks the cooldown should last for
8789
*/
88-
void setNewCooldown(int ticks);
90+
void setNewCooldown(Ticks ticks);
8991

9092
}
9193

src/main/java/org/spongepowered/api/event/item/inventory/UseItemStackEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.spongepowered.api.item.ItemType;
3131
import org.spongepowered.api.item.inventory.ItemStack;
3232
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
33+
import org.spongepowered.api.util.Ticks;
3334

3435
/**
3536
* Fired when an {@link ItemStack} is used.
@@ -41,21 +42,21 @@ public interface UseItemStackEvent extends Event {
4142
*
4243
* @return The original remaining duration
4344
*/
44-
int originalRemainingDuration();
45+
Ticks originalRemainingDuration();
4546

4647
/**
4748
* Gets the remaining duration of {@link ItemStack} in use.
4849
*
4950
* @return The remaining duration
5051
*/
51-
int remainingDuration();
52+
Ticks remainingDuration();
5253

5354
/**
5455
* Sets the remaining duration of {@link ItemStack} in use.
5556
*
5657
* @param duration The remaining duration to set
5758
*/
58-
void setRemainingDuration(int duration);
59+
void setRemainingDuration(Ticks duration);
5960

6061
/**
6162
* Gets the {@link ItemStack} being consumed.

src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@
4747
/**
4848
* Represents an event fired during the login process.
4949
*
50-
* <p>Together with {@link SpawnEntityEvent}, these events represent the
51-
* progression of a {@link ServerPlayer player} from first authenticating, to being fully
52-
* loaded in the world.</p>
50+
* <p>These events represent the progression of a {@link ServerPlayer player}
51+
* from first authenticating, to being fully loaded in the world.</p>
5352
*
5453
* <p>The events are fired in the following order:</p>
5554
*
56-
* <p>#Auth -&gt; #Handshake -&gt; #Login -&gt; {@link SpawnEntityEvent} -&gt; #Join</p>
55+
* <p>#Auth -&gt; #Handshake -&gt; #Login -&gt; #Join</p>
5756
*
58-
* <p>{@link SpawnEntityEvent} is still fired for players, for consistency.
59-
* However, the player is not at a well-defined state at that point. It's
60-
* recommended to use the event's subinterfaces to interact with the player
61-
* at well-defined moments during the connection process.</p>
57+
* <p>Traditionally one could consider a {@link SpawnEntityEvent} to be thrown,
58+
* but due to the nature of cancellations, a {@link ServerPlayer player} joining
59+
* a world after {@link Login login} would be inadvisable to cancel due to the
60+
* inconsistent state of both the player and the player's client.</p>
6261
*/
6362
public interface ServerSideConnectionEvent extends Event {
6463

@@ -182,11 +181,13 @@ interface Login extends ServerSideConnectionEvent, MessageEvent, Event, Cancella
182181
}
183182

184183
/**
185-
* Called when a {@link ServerPlayer player} joins the game within a {@link ServerWorld world} for the first
186-
* time after initial connection.
187-
*
188-
* <p>The {@link SpawnEntityEvent} for the {@link ServerPlayer player} is fired after the
189-
* #Login event. This event is fired after both.</p>
184+
* Called when a {@link ServerPlayer player} joins the game within a
185+
* {@link ServerWorld world} for the first time after initial connection.
186+
* Fired after {@link Login} once the {@link ServerPlayer player} has been
187+
* properly added to the {@link ServerWorld}. If data is wanted to be
188+
* modified that could affect a player's representation (such as vanishing),
189+
* it's recommended to modify such data in the logging in
190+
* {@link Login#user() User} instead.
190191
*/
191192
interface Join extends ServerSideConnectionEvent, AudienceMessageEvent, MessageCancellable {
192193

0 commit comments

Comments
 (0)