-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation Code Cleanup #1932
Changes from 1 commit
d1e64b4
f9a5591
49417f4
bb12e90
2f0bcb2
d2eb35b
3682d25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+1 −2 | src/main/java/org/spongepowered/api/extra/modifier/skylands/package-info.java |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import co.aikar.timings.Timing; | ||
import co.aikar.timings.TimingsManager; | ||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
import com.github.benmanes.caffeine.cache.LoadingCache; | ||
|
@@ -50,10 +51,12 @@ | |
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; | ||
import org.spongepowered.api.plugin.PluginContainer; | ||
import org.spongepowered.api.plugin.PluginManager; | ||
import org.spongepowered.asm.util.PrettyPrinter; | ||
import org.spongepowered.common.SpongeImpl; | ||
import org.spongepowered.common.event.filter.FilterFactory; | ||
import org.spongepowered.common.event.gen.DefineableClassLoader; | ||
import org.spongepowered.common.event.tracking.PhaseContext; | ||
import org.spongepowered.common.event.tracking.PhaseTracker; | ||
import org.spongepowered.common.event.tracking.phase.plugin.PluginPhase; | ||
import org.spongepowered.common.interfaces.IMixinContainer; | ||
import org.spongepowered.common.util.TypeTokenHelper; | ||
|
@@ -211,7 +214,7 @@ private void register(List<RegisteredListener<? extends Event>> handlers) { | |
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public void registerListener(PluginContainer plugin, Object listenerObject) { | ||
private void registerListener(PluginContainer plugin, Object listenerObject) { | ||
checkNotNull(plugin, "plugin"); | ||
checkNotNull(listenerObject, "listener"); | ||
|
||
|
@@ -241,7 +244,7 @@ public void registerListener(PluginContainer plugin, Object listenerObject) { | |
if (listener != null) { | ||
String error = getHandlerErrorOrNull(method); | ||
if (error == null) { | ||
@SuppressWarnings("unchecked") | ||
@SuppressWarnings({"unchecked", "rawtypes"}) | ||
final TypeToken eventType = TypeToken.of(method.getGenericParameterTypes()[0]); | ||
AnnotatedEventListener handler; | ||
try { | ||
|
@@ -372,7 +375,7 @@ public void unregisterPluginListeners(Object pluginObj) { | |
unregister(handler -> plugin.equals(handler.getPlugin())); | ||
} | ||
|
||
@SuppressWarnings({"ConstantConditions", "unchecked"}) | ||
@SuppressWarnings({"ConstantConditions", "unchecked", "rawtypes"}) | ||
protected RegisteredListener.Cache getHandlerCache(Event event) { | ||
checkNotNull(event, "event"); | ||
final Class<? extends Event> eventClass = event.getClass(); | ||
|
@@ -411,16 +414,18 @@ private boolean post(Event event, List<RegisteredListener<?>> handlers) { | |
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame(); | ||
final PhaseContext<?> context = PluginPhase.Listener.GENERAL_LISTENER.createPhaseContext() | ||
.source(handler.getPlugin()) | ||
.buildAndSwitch()) { | ||
handler.getTimingsHandler().startTimingIfSync(); | ||
.buildAndSwitch(); | ||
final Timing timings = handler.getTimingsHandler()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as here, note how it lines up with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess he referred to it being 5 spaces instead of 4 or 8. IIRC 8 is a common standard for this. Aligning it as it is here is also used but less common. As always: styles are just personal preferences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, looked really odd to me |
||
timings.startTimingIfSync(); | ||
if (event instanceof AbstractEvent) { | ||
((AbstractEvent) event).currentOrder = handler.getOrder(); | ||
} | ||
handler.handle(event); | ||
} catch (Throwable e) { | ||
// TODO - add some better handling, especially since we have the stakc frame and phase context to boot | ||
final PrettyPrinter printer = new PrettyPrinter(60).add("Error with event listener handling").centre().hr(); | ||
printer.add("A listener threw an exception while being handled, this is usually not a sponge bug.") | ||
this.logger.error("Could not pass {} to {}", event.getClass().getSimpleName(), handler.getPlugin(), e); | ||
} finally { | ||
handler.getTimingsHandler().stopTimingIfSync(); | ||
} | ||
Sponge.getCauseStackManager().popCause(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
@org.spongepowered.api.util.annotation.NonnullByDefault | ||
package org.spongepowered.common.item.inventory.query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra leading space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the proper indentation since it's a multiple try with resources.