Comments (5)
Option 1: Search text is only ever a single word. Page number set second.
Con: goes against what the current system uses of int after help.
//To handle the following:
///mv help
///mv help [text]
///mv help [text] [number]
//where [Text] is a string without spaces and [number] is an int or treated as 1 when invalid.
String sSearchTerm;
int iPage;
if (args.size() == 0)
{
sSearchTerm = "";
iPage = 1;
} else if (args.size() == 1) {
sSearchTerm = args.get(1);
iPage = 1;
} else if (args.size() == 2) {
sSearchTerm = args.get(1);
try {
iPage = args.get(2);
}
catch (NumberFormatException ex) {
iPage = 1;
}
}
//At this point, iPage and sSearchTerm are set.
//[Insert search for relevant return results.
from multiverse-core.
Option 2: Search text may be more then one word.
I don't know the syntax for getting the array of args for the foreach. From what I've read, the continue should be correctly written.
//To handle the following:
///mv help
///mv help [number]
///mv help [number] [text]
///mv help [text]
//where [Text] is a string that may contain spaces and [number] is an int or treated as 1 when invalid.
String sSearchTerm;
int iPage;
boolean isPageProvided = false;
if (args.size() == 0)
{
sSearchTerm = "";
iPage = 1;
} else {
//Get the page number. If it is a string, then it is a search
//term and paging defaults to first page.
try {
iPage = args.get(0);
isPageProvided = true;
}
catch (NumberFormatException ex) {
iPage = 1;
isPageProvided = false;
}
//Bring all of the search terms together, skipping the page number if
//it was provided.
boolean isFirstArg = true;
for(string sArg = args.getarray())
{
if(isFirstArg) {
isFirstArg = false;
if(isPageProvided) {
//When page is provided, skip the first arg, as it a number
//instead of a search term.
continue;
}
} else {
//Each additional search term needs spaced from the last.
sSearchTerm += " ";
}
sSearchTerm += sArg;
}
}
//At this point, iPage and sSearchTerm is set and ready to go.
from multiverse-core.
Ah yea, I was quite tired last night. If you look at the Info Command one of the params is WORLD, which if not provided is determined IF the sender was a player. That's why it was hairy... Since you've basically done all the work... I'll go add this tonight!
from multiverse-core.
Updated the comment. I was using base 1 instead of base 0 for the args.
//Was
iPage = args.get(1);
//Now
iPage = args.get(0);
If you ever want help hammering out variable validations from commands, ping me.
from multiverse-core.
Finished in: dbdc6d9
from multiverse-core.
Related Issues (20)
- [Bug]: bedrespawn?? HOT 2
- [Bug]: MV is not respecting doDaylightCycle gamerule. HOT 1
- [Idea]: add terraform gen to gens on wiki
- [Bug]:Virus detected HOT 2
- [Bug]: EntityCreatePortalEvent listener HOT 2
- [Feature Request] Add support for Paper's AsyncChat
- [Bug]: Very long chunk loading times when logging in after a server starts up with paper anti xray engine mode 3 HOT 3
- [Bug]: Buscript fails to load when world-container is modified HOT 1
- [Idea]: summon command to a precise location HOT 2
- [Bug]:"Server performance will be affected" HOT 2
- [Bug]: Please let the author know HOT 2
- [Idea]: Spawning not at spawnpoint when joining a world HOT 4
- [Bug]: Disabling passive mob spawn in any world doesn't work
- [Bug]: Double Charging players to use A built nether portal or end portal but doesnt double charge when teleporting HOT 1
- [Bug]: Execute the regen command multiple times, the seed has changed, but the world map remains the same, HOT 1
- [Bug]: Cant Break Blocks HOT 1
- [Idea]: Custom BGM for Each World
- [Bug]: Dimensions mixup
- [Bug]: Multiverse-Core make server LAG HOT 3
- [Bug]: worlds with the name "creative" is not allowing the items to be dropped HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multiverse-core.