Skip to content

Commit 98fac01

Browse files
committed
format remaining spigot code and make Dolphin#treasurePos nullable
1 parent 2db2ec9 commit 98fac01

22 files changed

+122
-192
lines changed

build-data/paper.at

+1-5
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z
274274
public net.minecraft.world.entity.animal.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V
275275
public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V
276276
public net.minecraft.world.entity.animal.Cat setVariant(Lnet/minecraft/core/Holder;)V
277+
public net.minecraft.world.entity.animal.Dolphin treasurePos
277278
public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_0
278279
public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_1
279280
public net.minecraft.world.entity.animal.Fox isDefending()Z
@@ -296,14 +297,9 @@ public net.minecraft.world.entity.animal.Rabbit setVariant(Lnet/minecraft/world/
296297
public net.minecraft.world.entity.animal.Salmon setVariant(Lnet/minecraft/world/entity/animal/Salmon$Variant;)V
297298
public net.minecraft.world.entity.animal.TropicalFish getPackedVariant()I
298299
public net.minecraft.world.entity.animal.TropicalFish setPackedVariant(I)V
299-
public net.minecraft.world.entity.animal.Turtle getHomePos()Lnet/minecraft/core/BlockPos;
300300
public net.minecraft.world.entity.animal.Turtle goingHome
301301
public net.minecraft.world.entity.animal.Turtle homePos
302-
public net.minecraft.world.entity.animal.Turtle isGoingHome()Z
303-
public net.minecraft.world.entity.animal.Turtle isTravelling()Z
304-
public net.minecraft.world.entity.animal.Turtle setGoingHome(Z)V
305302
public net.minecraft.world.entity.animal.Turtle setHasEgg(Z)V
306-
public net.minecraft.world.entity.animal.Turtle setTravelling(Z)V
307303
public net.minecraft.world.entity.animal.allay.Allay canDuplicate()Z
308304
public net.minecraft.world.entity.animal.allay.Allay duplicateAllay()V
309305
public net.minecraft.world.entity.animal.allay.Allay duplicationCooldown

paper-api/src/main/java/co/aikar/timings/TimingHistory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static class MinuteReport {
289289
final TicksRecord ticksRecord = new TicksRecord();
290290
final PingRecord pingRecord = new PingRecord();
291291
final TimingData fst = TimingsManager.FULL_SERVER_TICK.minuteData.clone();
292-
final double tps = 1E9 / ( System.nanoTime() - lastMinuteTime ) * ticksRecord.timed;
292+
final double tps = 1E9 / (System.nanoTime() - lastMinuteTime) * ticksRecord.timed;
293293
final double usedMemory = TimingsManager.FULL_SERVER_TICK.avgUsedMemory;
294294
final double freeMemory = TimingsManager.FULL_SERVER_TICK.avgFreeMemory;
295295
final double loadAvg = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();

paper-api/src/main/java/co/aikar/timings/TimingsManager.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ static TimingHandler getHandler(@Nullable String group, @NotNull String name, @N
153153
public static Timing getCommandTiming(@Nullable String pluginName, @NotNull Command command) {
154154
Plugin plugin = null;
155155
final Server server = Bukkit.getServer();
156-
if (!( server == null || pluginName == null ||
157-
"minecraft".equals(pluginName) || "bukkit".equals(pluginName) ||
158-
"spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName)
156+
if (!(server == null || pluginName == null ||
157+
"minecraft".equals(pluginName) || "bukkit".equals(pluginName) ||
158+
"spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName)
159159
)) {
160160
plugin = server.getPluginManager().getPlugin(pluginName);
161161
}

paper-api/src/main/java/org/bukkit/entity/Dolphin.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.bukkit.entity;
22

33
import org.bukkit.Location;
4+
import org.jetbrains.annotations.Nullable;
45

56
public interface Dolphin extends Ageable, WaterMob {
67

@@ -37,7 +38,7 @@ public interface Dolphin extends Ageable, WaterMob {
3738
*
3839
* @return calculated closest treasure location
3940
*/
40-
@org.jetbrains.annotations.NotNull
41+
@Nullable
4142
Location getTreasureLocation();
4243

4344
/**
@@ -48,5 +49,5 @@ public interface Dolphin extends Ageable, WaterMob {
4849
*
4950
* @param location location to guide to
5051
*/
51-
void setTreasureLocation(@org.jetbrains.annotations.NotNull Location location);
52+
void setTreasureLocation(@Nullable Location location);
5253
}

paper-api/src/main/java/org/bukkit/plugin/java/LibraryLoader.java

+52-56
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// CHECKSTYLE:OFF
21
package org.bukkit.plugin.java;
32

43
import java.io.File;
@@ -38,9 +37,8 @@
3837

3938
// Paper start
4039
@org.jetbrains.annotations.ApiStatus.Internal
41-
public class LibraryLoader
40+
public class LibraryLoader {
4241
// Paper end
43-
{
4442

4543
private final Logger logger;
4644
private final RepositorySystem repository;
@@ -49,83 +47,83 @@ public class LibraryLoader
4947
public static java.util.function.BiFunction<URL[], ClassLoader, URLClassLoader> LIBRARY_LOADER_FACTORY; // Paper - rewrite reflection in libraries
5048
public static java.util.function.Function<List<java.nio.file.Path>, List<java.nio.file.Path>> REMAPPER; // Paper - remap libraries
5149

52-
public LibraryLoader(@NotNull Logger logger)
53-
{
50+
public LibraryLoader(@NotNull Logger logger) {
5451
this.logger = logger;
5552

5653
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
57-
locator.addService( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class );
58-
locator.addService( TransporterFactory.class, HttpTransporterFactory.class );
54+
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
55+
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
5956

60-
this.repository = locator.getService( RepositorySystem.class );
57+
this.repository = locator.getService(RepositorySystem.class);
6158
this.session = MavenRepositorySystemUtils.newSession();
6259

6360
session.setSystemProperties(System.getProperties()); // Paper - paper plugins, backport system properties fix for transitive dependency parsing, see #10116
64-
session.setChecksumPolicy( RepositoryPolicy.CHECKSUM_POLICY_FAIL );
65-
session.setLocalRepositoryManager( repository.newLocalRepositoryManager( session, new LocalRepository( "libraries" ) ) );
66-
session.setTransferListener( new AbstractTransferListener()
67-
{
61+
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL);
62+
session.setLocalRepositoryManager(repository.newLocalRepositoryManager(session, new LocalRepository("libraries")));
63+
session.setTransferListener(new AbstractTransferListener() {
6864
@Override
69-
public void transferStarted(@NotNull TransferEvent event) throws TransferCancelledException
70-
{
71-
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
65+
public void transferStarted(@NotNull TransferEvent event) {
66+
logger.log(Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
7267
}
73-
} );
68+
});
7469

7570
// SPIGOT-7638: Add system properties,
7671
// since JdkVersionProfileActivator needs 'java.version' when a profile has the 'jdk' element
7772
// otherwise it will silently fail and not resolves the dependencies in the affected pom.
78-
session.setSystemProperties( System.getProperties() );
73+
session.setSystemProperties(System.getProperties());
7974
session.setReadOnly();
8075

81-
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
76+
this.repositories = repository.newResolutionRepositories(session, Arrays.asList(new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build()));
8277
}
8378

8479
@Nullable
85-
public ClassLoader createLoader(@NotNull PluginDescriptionFile desc)
86-
{
80+
public ClassLoader createLoader(@NotNull PluginDescriptionFile desc) {
8781
// Paper start - plugin loader api
8882
return this.createLoader(desc, null);
8983
}
84+
9085
@Nullable
9186
public ClassLoader createLoader(@NotNull PluginDescriptionFile desc, java.util.@Nullable List<java.nio.file.Path> paperLibraryPaths) {
92-
if ( desc.getLibraries().isEmpty() && paperLibraryPaths == null )
93-
// Paper end - plugin loader api
94-
{
87+
if (desc.getLibraries().isEmpty() && paperLibraryPaths == null) {
88+
// Paper end - plugin loader api
9589
return null;
9690
}
97-
logger.log( Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
98-
{
99-
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix
100-
} );
91+
logger.log(Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
92+
{
93+
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix
94+
});
10195

10296
List<Dependency> dependencies = new ArrayList<>();
103-
for ( String library : desc.getLibraries() )
104-
{
105-
Artifact artifact = new DefaultArtifact( library );
106-
Dependency dependency = new Dependency( artifact, null );
97+
for (String library : desc.getLibraries()) {
98+
Artifact artifact = new DefaultArtifact(library);
99+
Dependency dependency = new Dependency(artifact, null);
107100

108-
dependencies.add( dependency );
101+
dependencies.add(dependency);
109102
}
110103

111104
DependencyResult result;
112-
if (!dependencies.isEmpty()) try // Paper - plugin loader api
113-
{
114-
result = repository.resolveDependencies( session, new DependencyRequest( new CollectRequest( (Dependency) null, dependencies, repositories ), null ) );
115-
} catch ( DependencyResolutionException ex )
116-
{
117-
throw new RuntimeException( "Error resolving libraries", ex );
118-
} else result = null; // Paper - plugin loader api
105+
if (!dependencies.isEmpty()) {
106+
// Paper - plugin loader api
107+
try
108+
{
109+
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency) null, dependencies, repositories), null));
110+
} catch (DependencyResolutionException ex) {
111+
throw new RuntimeException("Error resolving libraries", ex);
112+
}
113+
} else {
114+
result = null; // Paper - plugin loader api
115+
}
119116

120117
List<URL> jarFiles = new ArrayList<>();
121118
List<java.nio.file.Path> jarPaths = new ArrayList<>(); // Paper - remap libraries
122119
// Paper start - plugin loader api
123120
if (paperLibraryPaths != null) jarPaths.addAll(paperLibraryPaths);
124-
if (result != null) for ( ArtifactResult artifact : result.getArtifactResults() )
125-
// Paper end - plugin loader api
126-
{
127-
// Paper start - remap libraries
128-
jarPaths.add(artifact.getArtifact().getFile().toPath());
121+
if (result != null) {
122+
for (ArtifactResult artifact : result.getArtifactResults()) {
123+
// Paper end - plugin loader api
124+
// Paper start - remap libraries
125+
jarPaths.add(artifact.getArtifact().getFile().toPath());
126+
}
129127
}
130128
if (REMAPPER != null) {
131129
jarPaths = REMAPPER.apply(jarPaths);
@@ -135,27 +133,25 @@ public ClassLoader createLoader(@NotNull PluginDescriptionFile desc, java.util.@
135133
// Paper end - remap libraries
136134

137135
URL url;
138-
try
139-
{
136+
try {
140137
url = file.toURI().toURL();
141-
} catch ( MalformedURLException ex )
142-
{
143-
throw new AssertionError( ex );
138+
} catch (MalformedURLException ex) {
139+
throw new AssertionError(ex);
144140
}
145141

146-
jarFiles.add( url );
147-
logger.log( Level.INFO, "[{0}] Loaded library {1}", new Object[]
148-
{
149-
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix
150-
} );
142+
jarFiles.add(url);
143+
logger.log(Level.INFO, "[{0}] Loaded library {1}", new Object[]
144+
{
145+
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix
146+
});
151147
}
152148

153149
// Paper start - rewrite reflection in libraries
154150
URLClassLoader loader;
155151
if (LIBRARY_LOADER_FACTORY == null) {
156-
loader = new URLClassLoader( jarFiles.toArray( new URL[ jarFiles.size() ] ), getClass().getClassLoader() );
152+
loader = new URLClassLoader(jarFiles.toArray(new URL[jarFiles.size()]), getClass().getClassLoader());
157153
} else {
158-
loader = LIBRARY_LOADER_FACTORY.apply(jarFiles.toArray( new URL[ jarFiles.size() ] ), getClass().getClassLoader());
154+
loader = LIBRARY_LOADER_FACTORY.apply(jarFiles.toArray(new URL[jarFiles.size()]), getClass().getClassLoader());
159155
}
160156
// Paper end - rewrite reflection in libraries
161157

paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
- consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list));
121121
+ consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list, true)); // Paper - data sanitization
122122
}
123-
+ ((LivingEntity) this.entity).detectEquipmentUpdatesPublic(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
123+
+ ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
124124
}
125125

126126
if (!this.entity.getPassengers().isEmpty()) {

paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch

+12-12
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@
578578

579579
this.player.connection.send(new ClientboundSetHeldSlotPacket(inventory.getSelectedSlot()));
580580
this.player.inventoryMenu.broadcastChanges();
581-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
581+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
582582
}
583583
}
584584

@@ -1113,7 +1113,7 @@
11131113
+ }
11141114
+ // CraftBukkit end
11151115
this.player.stopUsingItem();
1116-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1116+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
11171117
}
11181118

11191119
return;
@@ -1135,21 +1135,21 @@
11351135
+ }
11361136
+ // CraftBukkit end
11371137
this.player.drop(false);
1138-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1138+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
11391139
}
11401140

11411141
return;
11421142
case DROP_ALL_ITEMS:
11431143
if (!this.player.isSpectator()) {
11441144
this.player.drop(true);
1145-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1145+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
11461146
}
11471147

11481148
return;
11491149
case RELEASE_USE_ITEM:
11501150
- this.player.releaseUsingItem();
11511151
+ if (this.player.getUseItem() == this.player.getItemInHand(this.player.getUsedItemHand())) this.player.releaseUsingItem(); // Paper - validate use item before processing release
1152-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1152+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
11531153
return;
11541154
case START_DESTROY_BLOCK:
11551155
case ABORT_DESTROY_BLOCK:
@@ -1182,7 +1182,7 @@
11821182
+ }
11831183
+ }
11841184
+ // Paper end - Send block entities after destroy prediction
1185-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1185+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
11861186
return;
11871187
default:
11881188
throw new IllegalArgumentException("Invalid player action");
@@ -1257,7 +1257,7 @@
12571257

12581258
this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos));
12591259
this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction)));
1260-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1260+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
12611261
} else {
12621262
LOGGER.warn(
12631263
"Rejecting UseItemOnPacket from {}: Location {} too far away from hit block {}.",
@@ -1407,7 +1407,7 @@
14071407

14081408
this.player.getInventory().setSelectedSlot(packet.getSlot());
14091409
this.player.resetLastActionTime();
1410-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1410+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
14111411
} else {
14121412
LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
14131413
+ this.disconnect(Component.literal("Invalid hotbar selection (Hacking?)"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // CraftBukkit // Paper - kick event cause
@@ -2013,7 +2013,7 @@
20132013
+ });
20142014
+ }
20152015
+ // Paper end - PlayerUseUnknownEntityEvent
2016-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2016+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
20172017
}
20182018
}
20192019

@@ -2419,7 +2419,7 @@
24192419
} else {
24202420
this.player.containerMenu.broadcastChanges();
24212421
}
2422-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2422+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
24232423
}
24242424
}
24252425
}
@@ -2496,7 +2496,7 @@
24962496
if (flag) {
24972497
this.player.containerMenu.broadcastChanges();
24982498
}
2499-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2499+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
25002500
}
25012501
}
25022502
}
@@ -2545,7 +2545,7 @@
25452545
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack);
25462546
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack);
25472547
this.player.inventoryMenu.broadcastChanges();
2548-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2548+
+ this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
25492549
} else if (flag && flag2) {
25502550
if (this.dropSpamThrottler.isUnderThreshold()) {
25512551
this.dropSpamThrottler.increment();

0 commit comments

Comments
 (0)