本文整理匯總了Java中net.minecraft.server.MinecraftServer類的典型用法代碼示例。如果您正苦於以下問題:Java MinecraftServer類的具體用法?Java MinecraftServer怎麽用?Java MinecraftServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MinecraftServer類屬於net.minecraft.server包,在下文中一共展示了MinecraftServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processCommand
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 1 && args[0].length() > 0)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.deop.failed", new Object[] {args[0]});
}
else
{
minecraftserver.getConfigurationManager().removeOp(gameprofile);
notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.deop.usage", new Object[0]);
}
}
示例2: execute
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
new Thread(() -> {
try {
byte[] dataToDump = FullwidthPunctuationFix.INSTANCE.getCharWidthData();
File dest = new File(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks(), "autogen_glyph_width");
if (!dest.exists() || !dest.isDirectory()) {
dest.mkdir();
}
File dumpTargetDir = new File(dest, "assets/minecraft/font");
if (!dumpTargetDir.exists() || !dumpTargetDir.isDirectory()) {
dumpTargetDir.mkdirs();
}
File dumpTarget = new File(dumpTargetDir, "glyph_sizes.bin");
FileUtils.writeByteArrayToFile(dumpTarget, dataToDump, false);
File packMeta = new File(dest, "pack.mcmeta");
FileUtils.writeStringToFile(packMeta, "{ \"pack\": { \"pack_format\": 2, \"description\": \"Auto-generated glyph width data\" } }", "UTF-8", false);
sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.success"));
} catch (Exception e) {
sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.fail"));
}
}, "GlyphWidthDataExporter").start();
}
示例3: enablePlayerTrigger
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);
if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getOrCreateScore(s, scoreobjective);
score.setLocked(false);
notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例4: getUnformattedTextForChat
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
/**
* Gets the text of this component, without any special formatting codes added, for chat. TODO: why is this two
* different methods?
*/
public String getUnformattedTextForChat()
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getValueFromObjective(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
return this.value;
}
示例5: execute
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = sender.getEntityWorld();
if (!world.isRemote && args.length > 0)
{
EntityPlayer player = this.getCommandSenderAsPlayer(sender);
EntityCurse curse = null;
EnumCurseType curseType = EnumCurseType.byName(args[0]);
switch(curseType)
{
case CREEPER: curse = new EntityCreeperCurse(world, player); break;
case GHAST: curse = new EntityGhastCurse(world, player); break;
case SKELETON: curse = new EntitySkeletonCurse(world, player); break;
case SLIME: curse = new EntitySlimeCurse(world, player); break;
case SPIDER: curse = new EntitySpiderCurse(world, player); break;
case ZOMBIE: curse = new EntityZombieCurse(world, player); break;
}
world.spawnEntity(curse);
}
}
示例6: addTabCompletionOptions
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
}
else if (args.length != 2)
{
return args.length == 3 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null;
}
else
{
List<String> list = Lists.<String>newArrayList();
for (StatBase statbase : StatList.allStats)
{
list.add(statbase.statId);
}
return getListOfStringsMatchingLastWord(args, list);
}
}
示例7: addTabCompletionOptions
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[] {"on", "off", "list", "add", "remove", "reload"});
}
else
{
if (args.length == 2)
{
if (args[0].equals("remove"))
{
return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getWhitelistedPlayerNames());
}
if (args[0].equals("add"))
{
return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getPlayerProfileCache().getUsernames());
}
}
return null;
}
}
示例8: shouldCreateWorld
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
if (this.fwparams != null && this.fwparams.isForceReset())
return true;
World world = null;
MinecraftServer server = MinecraftServer.getServer();
if (server.worldServers != null && server.worldServers.length != 0)
world = server.getEntityWorld();
if (world == null)
return true; // There is no world, so we definitely need to create one.
String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
// Extract the name from the path (need to cope with backslashes or forward slashes.)
String mapfile = (this.mapFilename == null) ? "" : this.mapFilename; // Makes no sense to have an empty filename, but createWorld will deal with it graciously.
String[] parts = mapfile.split("[\\\\/]");
if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
return false; // We don't check whether the game modes match - it's up to the server state machine to sort that out.
return true; // There's no world, or the world is different to the basemap file, so create.
}
示例9: cleanQueryClientsMap
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
/**
* Removes all clients whose auth is no longer valid
*/
private void cleanQueryClientsMap()
{
if (this.running)
{
long i = MinecraftServer.getCurrentTimeMillis();
if (i >= this.lastAuthCheckTime + 30000L)
{
this.lastAuthCheckTime = i;
Iterator<Entry<SocketAddress, RConThreadQuery.Auth>> iterator = this.queryClients.entrySet().iterator();
while (iterator.hasNext())
{
Entry<SocketAddress, RConThreadQuery.Auth> entry = (Entry)iterator.next();
if (((RConThreadQuery.Auth)entry.getValue()).hasExpired(i).booleanValue())
{
iterator.remove();
}
}
}
}
}
示例10: StatsComponent
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
public StatsComponent(MinecraftServer p_i2367_1_)
{
this.field_120037_e = p_i2367_1_;
this.setPreferredSize(new Dimension(456, 246));
this.setMinimumSize(new Dimension(456, 246));
this.setMaximumSize(new Dimension(456, 246));
(new Timer(500, new ActionListener()
{
public void actionPerformed(ActionEvent p_actionPerformed_1_)
{
StatsComponent.this.func_120034_a();
}
})).start();
this.setBackground(Color.BLACK);
}
示例11: doCommand
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
FstPlayer player = new FstPlayer(sender);
player.runIfAirOrBlockHeld(() -> {
Map<String, Integer> argsInt = argsToInteger(copyArgs(args, 1),
"ux", "uy", "uz", "radius");
FstPos center = new FstPos(
argsInt.get("ux"),
argsInt.get("uy"),
argsInt.get("uz")
);
if("vt".equals(args[0])) {
buildVerticalCircle(player, center, argsInt.get("radius"));
} else {
buildHorizontalCircle(player, center, argsInt.get("radius"));
}
});
}
示例12: getTabCompletions
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, new String[]{"list", "add", "remove", "reload"});
}
else
{
if (args.length == 2)
{
if ("remove".equals(args[0]))
{
return getListOfStringsMatchingLastWord(args, server.getPlayerList().getWhitelistedPlayerNames());
}
if ("add".equals(args[0]))
{
return getListOfStringsMatchingLastWord(args, server.getPlayerProfileCache().getUsernames());
}
}
return Collections.emptyList();
}
}
示例13: lookupNames
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例14: processCommand
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
示例15: checkPermission
import net.minecraft.server.MinecraftServer; //導入依賴的package包/類
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
if (sender instanceof DedicatedServer)
return true;
EntityPlayerMP player = (EntityPlayerMP) sender;
GameProfile profile = player.getGameProfile();
UserListOpsEntry opEntry = (UserListOpsEntry) WorldBorder.SERVER
.getPlayerList()
.getOppedPlayers()
.getEntry(profile);
// Level 2 (out of 4) have general access to game-changing commands
// TODO: Make this a configuration option
return opEntry != null && opEntry.getPermissionLevel() > 2;
}