Fix a few IDE warnings (#1345)
This commit is contained in:
1 parent
e011f65e75
commit
b1c934da28
19 files changed
+225
-350
No files matched your search
@@ -870,13 +870,13 @@ public class CarpetEventServer
|
||||
{
|
||||
return stat.getType().getRegistry().getKey(stat.getValue());
|
||||
}
|
||||
private final Set<ResourceLocation> skippedStats = new HashSet<ResourceLocation>(){{
|
||||
add(Stats.TIME_SINCE_DEATH);
|
||||
add(Stats.TIME_SINCE_REST);
|
||||
//add(Stats.PLAY_ONE_MINUTE);
|
||||
add(Stats.PLAY_TIME);
|
||||
add(Stats.TOTAL_WORLD_TIME);
|
||||
}};
|
||||
private final Set<ResourceLocation> skippedStats = Set.of(
|
||||
Stats.TIME_SINCE_DEATH,
|
||||
Stats.TIME_SINCE_REST,
|
||||
//Stats.PLAY_ONE_MINUTE,
|
||||
Stats.PLAY_TIME,
|
||||
Stats.TOTAL_WORLD_TIME
|
||||
);
|
||||
@Override
|
||||
public void onPlayerStatistic(ServerPlayer player, Stat<?> stat, int amount)
|
||||
{
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package carpet.script.annotation;
|
||||
|
||||
import carpet.logging.HUDController;
|
||||
import carpet.script.annotation.Param.AllowSingleton;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
/* There is no worse example to use for 1.17 compatibility
|
||||
import static net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action;
|
||||
|
||||
public class FunctionsTestClass {
|
||||
@ScarpetFunction(maxParams = 6)
|
||||
public Integer display_title2(@AllowSingleton List<ServerPlayerEntity> targets, String actionString, Optional<Text> content, Integer... times) {
|
||||
TitleS2CPacket.Action action;
|
||||
switch (actionString.toLowerCase(Locale.ROOT))
|
||||
{
|
||||
case "title":
|
||||
action = Action.TITLE;
|
||||
break;
|
||||
case "subtitle":
|
||||
action = Action.SUBTITLE;
|
||||
break;
|
||||
case "actionbar":
|
||||
action = Action.ACTIONBAR;
|
||||
break;
|
||||
case "clear":
|
||||
action = Action.CLEAR;
|
||||
break;
|
||||
case "player_list_header":
|
||||
case "player_list_footer":
|
||||
action = null;
|
||||
break;
|
||||
default:
|
||||
throw new InternalExpressionException("'display_title' requires 'title', 'subtitle', 'actionbar', 'player_list_header', 'player_list_footer' or 'clear' as second argument");
|
||||
}
|
||||
if (action == null) // Player list
|
||||
{
|
||||
Map<String, BaseText> map = actionString.equals("player_list_header") ? HUDController.scarpet_headers : HUDController.scarpet_footers;
|
||||
if (!content.isPresent()) // null
|
||||
for (ServerPlayerEntity p : targets)
|
||||
map.remove(p.getEntityName());
|
||||
else
|
||||
for (ServerPlayerEntity p : targets)
|
||||
map.put(p.getEntityName(), (BaseText) content.get());
|
||||
return targets.size();
|
||||
}
|
||||
targets.forEach(p -> {
|
||||
if (times.length == 3) p.networkHandler.sendPacket(new TitleS2CPacket(Action.TIMES, null, times[0], times[1], times[2]));
|
||||
p.networkHandler.sendPacket(new TitleS2CPacket(action, content.orElse(null)));
|
||||
});
|
||||
return targets.size();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -16,7 +16,6 @@ import carpet.script.value.FormattedTextValue;
|
||||
import carpet.script.value.FunctionValue;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.NBTSerializableValue;
|
||||
import carpet.script.value.NullValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.ScreenValue;
|
||||
import carpet.script.value.StringValue;
|
||||
|
||||
@@ -12,7 +12,6 @@ import carpet.script.utils.InputValidator;
|
||||
import carpet.script.value.BooleanValue;
|
||||
import carpet.script.value.EntityValue;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.NullValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.script.value.FormattedTextValue;
|
||||
|
||||
@@ -607,7 +607,7 @@ public class WorldAccess {
|
||||
for (long key : levelTickets.keySet())
|
||||
{
|
||||
ChunkPos chpos = new ChunkPos(key);
|
||||
for (Ticket ticket : levelTickets.get(key))
|
||||
for (Ticket<?> ticket : levelTickets.get(key))
|
||||
{
|
||||
res.add(ListValue.of(
|
||||
new StringValue(ticket.getType().toString()),
|
||||
@@ -625,7 +625,7 @@ public class WorldAccess {
|
||||
SortedArraySet<Ticket<?>> tickets = levelTickets.get(new ChunkPos(pos).toLong());
|
||||
if (tickets != null)
|
||||
{
|
||||
for (Ticket ticket : tickets)
|
||||
for (Ticket<?> ticket : tickets)
|
||||
{
|
||||
res.add(ListValue.of(
|
||||
new StringValue(ticket.getType().toString()),
|
||||
@@ -1297,7 +1297,7 @@ public class WorldAccess {
|
||||
if (structureName == null) return Value.NULL;
|
||||
LongSet structureReferences = references.get(structureName);
|
||||
if (structureReferences == null || structureReferences.isEmpty()) return ListValue.of();
|
||||
return ListValue.wrap(structureReferences.stream().map(l -> ListValue.of(
|
||||
return ListValue.wrap(structureReferences.longStream().mapToObj(l -> ListValue.of(
|
||||
new NumericValue(16*ChunkPos.getX(l)),
|
||||
Value.ZERO,
|
||||
new NumericValue(16*ChunkPos.getZ(l)))).collect(Collectors.toList()));
|
||||
@@ -1509,7 +1509,6 @@ public class WorldAccess {
|
||||
if (first instanceof ListValue)
|
||||
{
|
||||
List<Value> listVal = ((ListValue) first).getItems();
|
||||
int offset = 0;
|
||||
BlockArgument locator = BlockArgument.findIn(cc, listVal, 0);
|
||||
requestedChunks.add(new ChunkPos(locator.block.getPos()));
|
||||
while (listVal.size() > locator.offset)
|
||||
@@ -1561,8 +1560,8 @@ public class WorldAccess {
|
||||
}
|
||||
}*/
|
||||
result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap(
|
||||
e -> new StringValue((String)((Map.Entry) e).getKey()),
|
||||
e -> new NumericValue((Integer)((Map.Entry) e).getValue())
|
||||
e -> new StringValue(e.getKey()),
|
||||
e -> new NumericValue(e.getValue())
|
||||
)));
|
||||
});
|
||||
return result[0];
|
||||
@@ -1599,7 +1598,7 @@ public class WorldAccess {
|
||||
BlockPos pos = locator.block.getPos();
|
||||
if (lv.size() != locator.offset+2) throw new InternalExpressionException("'add_chunk_ticket' requires block position, ticket type and radius");
|
||||
String type = lv.get(locator.offset).getString();
|
||||
TicketType ticket = ticketTypes.get(type.toLowerCase(Locale.ROOT));
|
||||
TicketType<?> ticket = ticketTypes.get(type.toLowerCase(Locale.ROOT));
|
||||
if (ticket == null) throw new InternalExpressionException("Unknown ticket type: "+type);
|
||||
int radius = NumericValue.asNumber(lv.get(locator.offset+1)).getInt();
|
||||
if (radius < 1 || radius > 32) throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks");
|
||||
|
||||
@@ -4,7 +4,6 @@ import carpet.script.CarpetContext;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.value.BlockValue;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.NullValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
@@ -99,56 +98,6 @@ public class BlockArgument extends Argument
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockArgument findInValues(CarpetContext c, List<Value> params, int offset, boolean acceptString, boolean optional)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value v1 = params.get(0 + offset);
|
||||
//add conditional from string name
|
||||
if (optional && v1.isNull())
|
||||
{
|
||||
return new BlockArgument(null, 1+offset);
|
||||
}
|
||||
if (acceptString && v1 instanceof StringValue)
|
||||
{
|
||||
return new BlockArgument(BlockValue.fromString(v1.getString()), 1+offset);
|
||||
}
|
||||
if (v1 instanceof BlockValue)
|
||||
{
|
||||
return new BlockArgument(((BlockValue) v1), 1+offset);
|
||||
}
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
|
||||
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getLevel(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
1+offset);
|
||||
}
|
||||
int xpos = (int) NumericValue.asNumber(v1).getLong();
|
||||
int ypos = (int) NumericValue.asNumber( params.get(1 + offset)).getLong();
|
||||
int zpos = (int) NumericValue.asNumber( params.get(2 + offset)).getLong();
|
||||
return new BlockArgument(
|
||||
new BlockValue(
|
||||
null,
|
||||
c.s.getLevel(),
|
||||
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
|
||||
),
|
||||
3+offset
|
||||
);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw handleError(optional, acceptString);
|
||||
}
|
||||
}
|
||||
|
||||
private static InternalExpressionException handleError(boolean optional, boolean acceptString)
|
||||
{
|
||||
String message = "Block-type argument should be defined either by three coordinates (a triple or by three arguments), or a block value";
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Operators {
|
||||
public static final Map<String, Integer> precedence = new HashMap<String,Integer>() {{
|
||||
public static final Map<String, Integer> precedence = new HashMap<String, Integer>() {{
|
||||
put("attribute~:", 80);
|
||||
put("unary+-!...", 60);
|
||||
put("exponent^", 40);
|
||||
|
||||
@@ -11,7 +11,6 @@ import carpet.script.value.BooleanValue;
|
||||
import carpet.script.value.FunctionValue;
|
||||
import carpet.script.value.ListValue;
|
||||
import carpet.script.value.MapValue;
|
||||
import carpet.script.value.NullValue;
|
||||
import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
|
||||
import java.util.Locale;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
|
||||
@@ -4,7 +4,6 @@ import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ScreenHandlerInterface;
|
||||
|
||||
import carpet.script.CarpetContext;
|
||||
import carpet.script.CarpetScriptHost;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.script.Context;
|
||||
|
||||
Reference in new issue
Block a user